On a POST request via Postman I pass the dealer id in the body of the request with the bearer token and run my test collection. Is there a way to set it as a variable and use a dealer id dictionary to loop through all of the values?
You can use csv as a source of those. See THIS blog post.
Related
I have used Postman to extract a number of ID's from a request. Now I would like to use those ID's in a new series of requests using Postman. I can't figure out how to do this, does anyone know?
There are several hundreds of ID's and below are some examples that I can see in the console (but they do not appear in the request Body)
(100) [373894, 373893, 373467, 373459, 372712, …]
0: 373894
1: 373893
2: 373467
3: 373459
I would like to use postman to send new requests for all these ID's where I would like to fill the brackets with the ID's in the request URL that now looks like this:
https://app.rule.io/api/v2/campaigns/{{}}/statistics
I've tested the ID's one at a time and they work fine but I would like to run them all to then collect the data and send it to Google Data Studio. (background is that I'm trying to send campaign data from an e-mail marketing tool into Google Data Studio and combine it with website data)
Postman is able to run user-defined test scripts after the call performed. So you could define an array variable, add an ID each time you obtain it. And then, use that array variable to make a call with the whole bunch of IDs you have.
Take a look this blog: https://blog.postman.com/extracting-data-from-responses-and-chaining-requests/
I am using HTTP requests via an Oracle database to extract data from Gmail APIs.
In Oracle, you apply all filters to either the URL of the request or its body.
This is working fine for simple requests such as the URL below to request list of unread messages in inbox for user:
https://gmail.googleapis.com/gmail/v1/users/me/messages?maxResults=500&q=is:unread&labelIds=INBOX
If I try to add more than one filter to the URL (or LabelIds) like in the URL below, I get an error response from the request:
https://gmail.googleapis.com/gmail/v1/users/me/messages?maxResults=500&q=is:unread newer_than:2d&labelIds=INBOX
I have tried multiple iterations for "q=" part like using double quotes, but anything I try outside of 1 filter returns an error response.
The documentation at https://developers.google.com/gmail/api/guides/filtering give this filtering example, but that clearly doesn't work for me:
https://www.googleapis.com/gmail/v1/users/me/messages?q=in:sent after:2014/01/01 before:2014/02/01
I tried removing the "is:unread" filter and adding it as a label, but I get a similar issue when trying to use multiple labelIds in the URL request. Using just labelIds=INBOX works fine, but using labelIds=INBOX,UNREAD or various iterations of that with quotes and square brackets all return error responses.
How do I use multiple filters (and/or multiple labelIds) in the URL of a request?
Thanks,
Dick
It looks like the problem is with the space between each filter in the q section.
If I add %20 for the space, it works.
For example, "https://gmail.googleapis.com/gmail/v1/users/me/messages?maxResults=500&q=is:unread newer_than:2d&labelIds=INBOX" will not work, but "https://gmail.googleapis.com/gmail/v1/users/me/messages?maxResults=500&q=is:unread%20newer_than:2d&labelIds=INBOX" will work.
i need to add this array in the parameters in Jmeter inorder to complete the POST request. And i am getting a 400 error.
This is the array, which needs to have a POST request:
conditions :[{accountStatus: 'UNVERIFIED'}, {accountStatus: 'INVITED'}]
Just add a Parameter with blank name and put your JSON array as a value like:
You can use View Results Tree listener to inspect request and response details:
Also make sure you add HTTP Header Manager to send at least Content-Type header with the value of application/json
Add the JSON data in Body Data tab instead of parameters tab.
Another solution:
Add to the list of variables
Name - "someArray[0]"
Variable - "someText"
See more about Request options here
Below is my restangular delete request where i intend to pass an array of ids to delete based on user selection
var deleteIds = [1,5,10]
Restangular.all('url').customDELETE(deleteIds);
I want this deleteIds to be passed in body params. How can i send the array as body so tat i could see the request payload.
Actually I also needed to use the delete http method with data passed in the body, and I found that Restangular supports a customOperation
documentation:
https://github.com/mgonto/restangular#custom-methods
customOperation(operation, path, [params, headers, elem]): This does a custom operation to the path that we specify. This method is actually used from all the others in this subsection. Operation can be one of: get, post, put, remove, head, options, patch, trace
example:
Restangular.all('some/path/123')
.customOperation('remove', '',{'content-type': 'application/json'},[1,5,10])
Depending on the backend technology you use, the body might be ignored for DELETE requests. See this question for more info.
I would suggest you to pass the id's as a part of the url.
I'm using Spring data REST named methods for my REST API. Some of exposed resources look like this:
Courses entity:
localhost:8080/data/courses/
Modules entity:
localhost:8080/data/courseModules
Each course can have multiple modules so I also have this:
localhost:8080/data/courses/{courseId}/modules - list of modules that are associated with course.
If I want to add new module I can naturally do this in two steps:
First add new module (with POST to localhost:8080/data/courseModules)
Associate newly added module with course (another POST to localhost:8080/data/courses/{courseId}/modules)
Question is:
Is it possible to do it in one step? I'm using Restangular and the way it works would suggest that this should be possible. With Restangular I would do something like this:
Restangular.one('courses', {courseId}).all('modules').post(newModule);
where newModule is json object.
Restangular than issued POST request to address: localhost:8080/data/courses/{courseId}/modules
This doesn't work hovewer. I'm getting "204 No Content" and no new object is added to my database. I can add new module making POST to this address: localhost:8080/data/courseModules but it would be so much easier if I could just make this request to localhost:8080/data/courses/{courseId}/modules. I expected that Spring Data REST will accept my POST request to localhost:8080/data/courses/{courseId}/modules and than automatically do the following:
Add new module
Create association of new module with course of id {courseId}
Thanks in advance for any hints.
The answer to the question YES. Following will be an approach i would like to suggest to you.
Say you have a scenario were
Add new course and modules
Delete an existing module.
Approach for scenario 1:
Endpoint URL : localhost:8080/data/courses/ HTTP Method : POST
The request body will be a JSON/XML which will have something like:
Course name [Module1, Module 2.....]
Approach for scenario 2:
Endpoint URL : localhost:8080/data/courses//id HTTP Method : DELETE
The request will contain an id of the module that has to be deleted.
Hope this ansers your question. Please let me know if you have any more question