Postman Collection to run multiple times - possible to send random unique ID in json body? - postman

I would like to measure the POST and GET endpoint performance by using POSTMAN collection - run feature.
ideally, i wanted to use same POST endpoint, but the json data is different at each iteration.
Possible to do that in POSTMAN?

In the postman api you can write scripted tests where you can change the data between each test. It can be the same request with different data.
Also you can use dynamic variables in the sandbox
I hope this helps

Related

How to filter Reports result from Docusign Rest API in Postman

I want to download the result of one on my custom reports so I've configured Docusign Rest API in Postman and I use the Account--> reports/report_results method to obtain the data.
After configuring the body with the ID and the customID, I see that the data of the report is there but as I have a lot of data, I want to filter it by the date. Do you know how to do it?
This endpoint is not a public endpoint. Meaning, it was exposed by mistake in a prior swagger file, but now is hidden.
You cannot use this endpoint of the eSignature API as it will soon be completely removed (part of a deprecation process).

Postman- Pass dynamic parameters to collection at run-time which is not part of response

I have created postman collection for unit testing of APIs.
I need to handle below scenario.
My second API generates OTP and sends it over email but its not part of response.
I want to pass that OTP in request body of 3rd API.
I am executing postman collection using Collection Runner.
Is there any way I can pause the execution and set this environment variable and then resume.
Or any other better option. Please suggest.
There is a way to do it but it require some knowledge of server side technologies ( for example Spring boot). you can create a new api which is kind of wrapper over your OTP api and it will read the OTP from either your mail/DB and send it as a part of Http response and then you can use that wrapper API in your Postman collection to fetch the OTP and then save it as a env variable and use it in further apis. I am also doing the same way.

Django: Send a Post Request Through Form to Another Server

I have a form on a template on my domain1 and want to send a POST request to domain2. I am using Django as the framework. I only want domain2 to accept requests from domain1 and domain2 (itself). However, I run into csrf problems.
You need a RESTful API. That's a very large topic and would be dumb/impossible to do the work for you here with the info I've been given, so here's a summary.
I suggest Django Rest Framework for making api's.
What the above means, is that when you want to do this sort of stuff (POST requests from other domains), you need a token. This is usually done with a Json Web Token. Also known as JWT's.
The process goes like this:
Get access token from other site to have permission to use the API from that site. Certain http headers, passwords, etc, are often included with this every single time data is exchanged.
Once you get a response giving you permission, you can now perform the type of request you want, with the data you want.
The data format for all this is USUALLY done with JSON. So you will have to import json, then json.dumps(obj) to turn it into valid json, and json.loads(obj) to turn your response into a python dictionary, so you can use it in your template, or wherever you want.
If you want to see an example of this, I recently made a free GoFundMe clone on my guthub. In the donate() view at the bottom, it uses the requests library, and shows how a JWT is obtained and used. You can see it there.

Why use URL parameters over request body in API?

When making an API endpoint in Django Rest Framework for example, why would I ever use URL parameters to receive data rather than just putting everything in the request data?
I don't get the difference between the two.
Putting some query data in the URL allows the URL to store the "state" of your web application.
For example a state can be "I queried how do I make cheese on stackoverflow", and the URL would be https://stackoverflow.com/search?q=how+do+make+cheese.
This allows the web app to interact as expected with browser tools like Refresh, Go Back, etc. Without the state stored in the URL, refreshing the page might just take you back to the homepage, instead of showing you the same query results (the expected behaviour).
Additionally, you can copy & paste the URL. When someone clicks on it, they will be taken directly to that specific state.
On the other hand, you shouldn't use the URL to store/send sensitive data (as it can easily be seen, use the body instead), and you should make sure reloading an "action" URL won't execute the action again (like paying for a product twice!).
The URL parameters and body parameters server different purpose. The REST API grammar says
GET Method is used when you want to retrieve data back and don't want to update any of the record in system. The GET method will not pass body parameter and hence whatever filter parameters passed to API will be through URL parameters.
POST/PUT Method is used whenever you want to update your database. The value could be single parameter or even no input but you have to use POST/PUT method, if you are trying to update database record(s).

Server Side Get Request with AWS API Gateway

This api that I am using only allows server side get requests and does not allow for get requests to come directly from the browser. They use basic auth like this Authorization: Basic YTcxODNlMWI3ZTlhYjA5YjhhNWNmYTg3ZDE5MzRjM2M6. So as long as you include the appropriate api key in the header all is well. I set up a get request in Amazon's API Gateway that grabs only the first 500 users (max is 500 that I can return at one time) from the api and returns those to the DOM with my custom url with my api key in the header. I have the ability to set query string parameters like this: users?page=1&per_page=500.
Since the api does not return how many pages of users there will be, how do I set up AWS API Gateway in order to scale this? For instance if we have 2400 users, will have to keep going back and creating get requests but with different page numbers or could I use AWS Lambda and pass in the page number as a variable and loop through until the results are less than 500? Any help is appreciated.
Yes I think using passing page number and number of result to return (which is 500 in your case ) to lambda function is right way to doing it.