"Client Error" message when trying to implement an Rest API View - rest

I'm creating an API with Drupal to serve a angular application. The problem is, when I create the view with Rest export and try to access it (via browser or postman), it gaves me an "Client error" message (and nothing more).
I'm using drupal-8.7.6, running with PHP7.3, mysql and apache 2. But I've tried at nginx also and the error appeared again.
To reproduce it, just add some contents, enable the Restful web services, jsonm hal and create a view that exports rest data.
I expect to access the information via GET request (using browser, postman or any other way)

Go to your View
Go to Format
Click on Settings beside Serializer
Finally check Json option and save.
You are done :)

find out what was happening
I was not specificating the format of output, so Drupal was searching for an html to serve. To workaround this, just add to url: ?_format=json, for example, if my view route is "/articles", it will be: http://drupal.dev/articles?_format=json

Go to the rest exports view, click on format setting and click accepted request format to json.

Related

Aqueduct template db_and_auth not rendering login form

I am working on setting up OAuth 2.0 for aqueduct and want to start with a working example. The template db_and_auth is suppose to serve this purpose.
I have followed the readme instructions and connected my database and updated the migration. also I have registered OAuth 2.0 clients in the application database as the readme describes.
The template comes with a route in the channel.dart
router
.route("/auth/form")
.link(() => AuthRedirectController(authServer, delegate: this));
The AuthRedirectController is set up to render a html page (web/login.html) which is part of the template.
However every time I send a get request to this route it returns with a 400 error saying Error
unsupported_response_type in the browser. Additionally in the readme file it only shows testing auth end points using curl. Why would this template include a rendered login page without mention of it in the readme? Any help with this would be much appreciated.
The login form will only be rendered when you pass the correct response_type like so:
http://localhost:8888/auth/form?response_type=token

Postman can't seem to find my backend api and I can't find out why

I've written a backend api in .net and I would like to test my methods but when I open postman and try my different methods, it never works:
Could not get any response
There was an error connecting to xxx/api/videos
The strange thing is that if I click the embedded link, it takes me to the right page of my api and shows me the json that I expect (now I use this url as an example, I want to test a post method and I con't view this one in the browser). If any of you know what to do, let me know.
click here in settings, one pop up window will get open. There we have switcher to make SSL verification certificate. Switch to (Off).

FlowRouter Reload Doesn't Route

I'm using FlowRouter. If I start on the homepage everything works well. I can work through the routes (change the pages) without problem. However, if I hit refresh in the browser, I get a series of errors. My url looks like this:
/story/586d536e34821281735b53a4
The ID is being returned in console under the following method:
Tracker.nonreactive(function(){
I think the subscription is being completed, so I'm a little confused as to why reloading a url is different than loading from the home page.
What am I not understanding here?
Reloading a url will make a HTTP request to server to get all the application source. Whereas navigating to a route from another one does not make any HTTP requests to get the application source because they are already available (they were loaded from the previous route), in this case the router will just get the appropriate content and render on the page. This is normal behaviour for Meteor apps and all other single-page apps
The error you encounter is because your data is not yet available on client, to fix it you could simple use a placeholder if the value is undefined.

How to call SOAP service from Phonegap (iPhone app)

I am trying to call a SOAP service using this SOAP client but it is not working for me. Please help me. How can I send and receive XML SOAP with Phonegap?
Phonegap is HTML/JS/CSS commonly communicating via XHR/Ajax. It's better to use jQuery Ajax functions. You can get the details here.
Eg:
Posting-XML-SOAP-Requests
AJAX-Requests-Between-jQuery
Simple jQuery client to call a SOAP web service
If you find any cross-domain issues (or working in a browser and not working with simulator/device), please refer to the below steps.
Go to the Resources folder, you can see a file named Cordova.plist. Click on that and you can see the Root elements. Right click on the Root, add a row, set the key as ExternalHosts with type Array.
Expand the item, and add an item as item0. Give it type string and enter the value as '*'.
Don't forget to save the Cordova.plist after changes (just use cmd+s).

Why GWT URL doesn't change on an event or a service call?

I have two questions:
Q: 1
I'm currently developing a GWT app. The entry point for the app is: ImageViewer.java. I could well access it by http://127.0.0.1:8888/ImageViewer.html?gwt.codesvr=127.0.0.1:9997. I have a service called "Search" which has corresponding "Async" and "Impl"'s defined. Now, I call the service from client side, using RPC. I could call the service, obtain return value. Everything works fine.
However, I expect the application to show a behavioral change on URL. i.e. when a service is being accessed, I thought it would be reflected on the browser's URL something like: http://127.0.0.1:8888/search?gwt.codesvr=127.0.0.1:9997 as I've modified web.xml. However, this behavior is not realized. Any particular reason why this is not reflected??
Q:2
This one is a reverse of the previous ques. i.e. I have an application running. Let's say it has an entrypoint class(Imageviewer.java) and another composite class (searchClass.java) which would be loaded on the Imageviewer based on an event. This searchClass invokes the "search" service mentioned in the previous question.
I could load the "searchClass" in "Imageviewer", invoke the service, and the service also returns the value needed. Everything works fine... But,
I need something like this: by just typing this query string:
http://127.0.0.1:8888/search?value=John
I want the "searchClass" to be loaded on the "ImageViewer", call the service using the value(which is "john" in this case) and display the result. Is this possible at all?
what I've tried: I have tried to create a httpServletClass on the server and mapped it with the URL and could do the search. The search returns appropriate results. However, I want the results from the server to be displayed on the client. Remember, I'm directly using a servlet to read the URL and so there is no value being passed from client to server.
Thanks in advance.
A: 1. To change URL, the hash part, you need to set new history token in the History class. More about history management in this article.
A: 2. For the second part you could achieve it by changing the history token, for instance "http://127.0.0.1/search#value=John". The history service will trigger an event if the # part changes. You could also use the part with "?", as in your example, if you use Window.Location , but it will cause reload of the application, which would put the whole idea of using GWT in question.
RPC (AJAX) calls are done Via XHR and do not change the browser URL.
You can't (with the URL you presented). GWT apps normally run in one web page, i.e. the URL does not change (see how gmail changes browser url bar). What you can do is enable GWT history support. Then your url would be http://host/#search?value=queryu