if I want to use postman to sendRequest to an html page (as part of a pre-request script), is there any way I can wait for it to fully render before getting the response?
My html page has ajax calls - currently
sendRequest(credentials, function(err,res){....})
just gets "Loading...." text.
What I want is the html AFTER the ajax calls have completed on the page.
Is this possible?
thanks
Phil
Related
I currently have an issue where i am sending formData from the UI through Ajax to the backend, however, i also created an helper function within the form to allow Image compression whilst it receives the data from the frontend. When the form encounters an exception while compressing, it doesn't return the error to the User until the AJAX request has gotten a response from the server and then i reload the page, I am thinking of using JS to reload the page if the response if false to display the error. Is this a better implementation or how should i go about it?
Am am currently using Postman to test the api results. I have been following the apostrophe headless docs, since am completely new to this. so what i need is to submit a post request in Postman to add a piece and its fields from REST api. I have got the bearer token and login was success. but when i insert a piece with body as JSON schema. am getting a error message.
May be the way am doing is wrong. so can one one help me in Making a post request to add piece and fields through POSTMAN atleast?
I did not understand the question quite right. You should add some of your inputs, error message, url, pics and etc. to clarify the problem.
However, if you need an example to how to use postman to make a POST request, it's like this:
Select the POST method and insert the API URL (The landing url for POST method not the view and etc.)
Go to headers Tab and add the Authorization token to header
Select the Body tab; Then raw type and finally JSON type. Now insert the Json body and click Send.
You can see the result of webservice call on the top of response window. If it returned 200, everything was OK.
Am am currently using Postman to test the api results. I have been following the apostrophe headless docs, since am completely new to this. so what i need is to submit a post request in Postman to add a piece and its fields from REST api. I have got the bearer token and login was success. but when i insert a piece with body as JSON schema. am getting a error message.
May be the way am doing is wrong. so can one one help me in Making a post request to add piece and fields through POSTMAN atleast?
I did not understand the question quite right. You should add some of your inputs, error message, url, pics and etc. to clarify the problem.
However, if you need an example to how to use postman to make a POST request, it's like this:
Select the POST method and insert the API URL (The landing url for POST method not the view and etc.)
Go to headers Tab and add the Authorization token to header
Select the Body tab; Then raw type and finally JSON type. Now insert the Json body and click Send.
You can see the result of webservice call on the top of response window. If it returned 200, everything was OK.
while i am running collection on postman than authentication fail is showing but manually one by one request is running proper after hitting update request on authentication page.i want pre-request script to hit update request button on authentication page .If anybody have idea please do share
Instead of using a pre-request script, try ticking (or clearing?) the "Save helper data to request" checkbox for each request in your collection. Screenshots and vague mentions of this feature are available at https://www.getpostman.com/docs/postman/sending_api_requests/authorization.
I am trying to build a Django powered website. I want the website to be dynamic. For example, I want the profile page for a authenticated user to contain multiple resources (like a friends list, a group list, usage history etc) and these resources should be loaded in the same area on the page by making API calls without reloading the page.
Here is my understanding of the process:
Browser on the client side requests the profile page at www.example.com/user:id
The server returns a HTTP response and sends the html, css and javascript to the browser.
To load variable resources on the webpage, for example, the friend list, the javascript makes API calls using HTTP and sending context in JSON.
The API returns a JSON response which contain the data requested.
Javascript renders the data as html and the client is able to see new content on the same page.
I thought that in order to do this, some of my server side views need to be ordinary Django views which returns an HTTP response, while some others need to be API views which return JSON.
Now here's my confusion. Let's say www.example.com/user:id is processed using an ordinary django view, while www.example.com/user/:id/friendslist is processed using an API view. Now if the user inadvertently points the browser at www.example.com/user/:id/friendslist by typing the entire URL and hits go, what happens?
If I go with the flow of logic that I mentioned above, then the view will simply return a JSON. No html, css or javascript. In this case, how will the browser know what html to display?
I am just a beginner and I am sure I got the flow of logic wrong. Can someone please point out which part I got wrong?
Now if the user inadvertently points the browser at www.example.com/user/:id/friendslist by typing the entire URL and hits go, what happens?
It depends on how you coded your server. In Django you can use is_ajax to check whether the request was AJAX or not. You could return an HTTP error code when the request is not an AJAX one, if you wanted. So a user who inadvertently points the browser to your URL but does not take any further action will get an error.
Note here that a knowledgeable user could circumvent is_ajax by setting the request header field HTTP_X_REQUESTED_WITH to XMLHttpRequest manually.
If I go with the flow of logic that I mentioned above, then the view will simply return a JSON. No html, css or javascript. In this case, how will the browser know what html to display?
Setting your returned data type to application/json already tells the browser what it is dealing with. The least a browser would do this with this is display it as text.
Here's an example of an API call that returns JSON: https://api.zotero.org/users/475425/collections/9KH9TNSJ/items?format=json My browser just shows the JSON.