Postman: How to pass an array within an http header - arrays

So far I tried: (In Bulk Edit)
myHeader:myValue1,myValue2,myValue3
myHeader:[myValue1,myValue2,myValue3]
myHeader:{myValue1,myValue2,myValue3}
Unfortunately I cannot say if one of these should work as I'm using a foreign API and I don't know if I'm maybe doing wrong something different which lets the request fail.
This answer How to pass an array within a http header? seems wrong to me as the answer suggests to put the header in the params...

You can add key value parameters from the postman desktop app. You can add the content-type, auth token and things like that. Here is an example. Good Luck!

Maybe too late, but for others:
Try to add your header multiple times

Related

endsWith filter not supported

I am trying to use endsWith filter on /users endpoint but I feel like I'm losing my mind. It simply doesn't work for me in the official example:
https://developer.microsoft.com/en-us/graph/graph-explorer?request=users%3F%24count%3Dtrue%26%24filter%3DendsWith(mail%2C%27%40hotmail.com%27)%26%24select%3Did%2CdisplayName%2Cmail&method=GET&version=v1.0&GraphUrl=https://graph.microsoft.com&headers=W3sibmFtZSI6IkNvbnNpc3RlbmN5TGV2ZWwiLCJ2YWx1ZSI6ImV2ZW50dWFsIn1d
In this example, the problematic header 'ConsistencyLevel' is set, but it doesn't help. So what's going on here ? I'm actually interested in the 'mail' property for endsWith, but if the official example doesn't work than I'm not sure what to expect.
edit:
I have tried the same Query WITHOUT ConsistencyLevel:eventual and it failed with same error.
https://graph.microsoft.com/v1.0/users?$count=true&$search="displayName:room"&$filter=endsWith(mail, '#microsoft.com')&$orderBy=displayName&$select=id,displayName,mail
As a solution , I tried the same Query WITH ConsistencyLevel:eventual and it worked.
Note: Add the ConsistencyLevel Eventual in request header and provide the appropriate Consent permission to make it work.
https://graph.microsoft.com/v1.0/users?$count=true&$search="displayName:room"&$filter=endsWith(mail, '#microsoft.com')&$orderBy=displayName&$select=id,displayName,mail

Superagent: PUT-ing multipart form data

Is it possible to do a PUT request with multipart form data?
With Superagent I would expect the following to work, but it doesn't.
var request = Request
.put("http://localhost:8080/upload_file")
.field("name", file.name)
.field("size", file.size)
.attach("file", file.file, file.file.name)
.accept("application/json")
If I do a post, it works. The difference is the Content-Type. With the successful post request the Content-Type is multipart/form-data; boundary=------WebKitFormBoundaryXg34NkBFcYWq60mH.
If I were to set this manually how would I know what the boundary should be? It seems to be automatically generated by Superagent.
You should probably do a POST, per Tum's comment.
If I were to set this manually how would I know what the boundary should be? It seems to be automatically generated by Superagent.
You should let Superagent manage that by itself - don't try to set the type yourself, leave off the type call and it will include the correct boundary identifier when it sets it as multi-part itself.
No, it is not possible to do a PUT request with content-type multipart/form-data due to an underlying limitation in PHP as discussed here: https://bugs.php.net/bug.php?id=55815
You might want to take a look at a 'hack' that was done for Symfony in Chekote/symfony: https://github.com/Chekote/symfony/commit/dc1279b2e4c0e9cbcb5b7d578891c31dd878b43b

Camel: POST-request routing by URL-pattern

I'm trying to catch some POST-request, log a message (and maybe a body or params in future); then pass them further to booHost, so the client will get the result of the call:
from("restlet:http://localhost:8090/api/endpointFoo?restletMethod=post")
.log("oh, it's a message!")
.routeId("someAPI")
.to("http://booHost:8090/api/endpointFoo?bridgeEndpoint=true&restletMethod=post");
That works just GREAT.
But:
What I need is the URL-pattern that will work that way. I'm trying:
from("restlet:http://localhost:8090/api/{endpoint}?restletMethod=post")
.log("oh, it's a message!")
.routeId("someAPI")
.to("http://booHost:8090/api/{endpoint}?bridgeEndpoint=true&restletMethod=post");
The "from" shots when I make the post. The message is logged.
But "to" seems not to treat {endpoint} as a param - it treats it like a constant; so the result of that call fails.
I don't need hardcoded endpoints because booHost API should be extended in future without Camel changes.
In other words, I need all calls to http://localhost:8090/api/* to be catched and resent to http://booHost:8090/api/* on the same endpoint.
Maybe I should use another component? Or How can I make it this way?
Thanks.
Thanks to #vikingsteve I've started to read about recipientList.
I've modified my code according to this FAQ question
The final version looks like this:
from("restlet:http://localhost:8090/api/{endpoint}?restletMethod=post")
.log(LoggingLevel.INFO, "POST-request to /${headers.endpoint} was sent")
.routeId("someAPI")
.recipientList(simple("http://booHost:8090/api/${headers.endpoint}?bridgeEndpoint=true&restletMethod=post"));
It works as suggested.

Getting $http.put() to send correctly formatted data, instead of JSON object

So, I spent some time and built a quick API for a project that I'm doing for myself.
I used the Postman add-on for Chrome to mimic PUT and DELETE quests to make sure everything worked correctly. Really happy I did that, as I learned a lot about PHP's shortcomings with PUT and DELETE requests.
Using the API I've had working with Postman, I started moving everything over to AngularJs controllers and such.
I'm trying to get a user to claim a row in a database as the login information for the users is different than this particular information. I couldn't figure out why the put requests to claim the row in my database wasn't working. Lo and behold, the data being parsed from my parsestr(file_get_contents('php://input')) had 1 array key, which was a JSON string.
I've looked, and I can't seem to find a solid answer either through Stackoverflow or Google (maybe I missed it somewhere in the config options), So my question is this: is there any way I can get the $http.put call send the data to the server correctly?
Thanks to user Chandermani for pointing me to the link at this URL which answered the base of my question.
From the above link, I found myself on This Blog post submitted by another user. In the end, what I ended up doing was the following:
taking param() function from the above link, as well as implementing these lines of code:
var app = angular.module('ucpData', [] , function($httpProvider){
$httpProvider.defaults.transformRequest = [function(data) {
return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
}];
});
Is how I worked around the problem. For some developers, you may actually want to keep the default transformRequest settings, but for the project I am doing I know that I will end up forgetting to call param() at some point, and my server doesn't naturally accept json data anyway. I would caution future developers to consider what they are attempting to do before they alter the transformRequest array directly.

How to rewrite function used POST metod to use also GET method in LoadRunner?

For POST method I have this piece of code in LR (it is working):
web_custom_request(transname,
URL,
"Method=POST",
"TargetFrame=",
"Mode=HTML",
"Resource=0",
"Referer=",
EncodingType,
lr_eval_string(request),
LAST);
This piece of code is placed in a separated .c file and called from user_init using a long sequence of related functions working with XML, arrays, strings data.
URL for POST requests has structure in user_init like this:
URL=https://{HOST}/aaa/bbb/page.asp
Also user_init contains this piece of code:
web_custom_request("Login_page",
"URL=http://{HOST}/api/04_00/Pr_NAME.asp",
"Method=POST",
"RecContentType=text/xml",
"Body="
"<?xml version=\"1.0\"?>"
"<Request xmlns=\"http://api.rr.com/Pr_NAME\">\r\n"
" <MethodRequest>\r\n"
" <AuthenticateUserRequest appID=\"value_appID\" password=\"value_password\">\r\n"
" <User>\r\n"
" <LoginName>value_LoginName</LoginName>\r\n"
" </User>\r\n"
" </AuthenticateUserRequest>\r\n"
" </MethodRequest>\r\n"
"</Request>\r\n",
LAST);
I need something additional to this code, that will allow to send both POST and GET requests to web-service. Now it sends only POST requests.
There are some questions:
1) How should I change this function to get the possibility to send both types of requests, POST and GET? What strings should I add to this function?
2) How should I change the URL for GET requests?
I think, it should be something like this:
URL=https://{HOST}/aaa/bbb/page.asp?param1=value1&param2=value2...&paramN=valueN
But what parameters should I add as param1, param2, ..., paramN?
How to define, how many and what parameters I need put in this URL construction?
Should I write this structure:
URL=http://{HOST}/api/04_00/Pr_NAME.asp?appID=value_appID&password=value_password&LoginName=value_LoginName
or shouldn't I add LoginName=value_LoginName in this structure?
3) How can I combine both 2 methods POST and GET in 1 function, to have the possibility to send both types of requests, POST and GET, from LR?
Please, could you help me? I'm a novice in data transferring in LR using POST and GET methods and functions.
Here are some answers (not entirely related to LR).
1) POST and GET are HTTP verbs that tell the server what you expect it to do with your request. There is no rules on what the server should do but instead conventions. The conventions are:
GET - Tells the server: Please give me data related to the parameters I provide in the querystring.
POST - Tells the server: Here is some data in the body of this request, please do something with it (usually but not always create a record of something).
There is no sense of sending both types of verbs in the same request.
In any case to set the verb use the "method" parameter (in your example it says "Method = POST" so you can change it to "Method = GET".
2)GET request sometimes needs parameters. As a convention you don't send those parameters in the Body but in a structure called querystring which comes after the URL separated by "?". The querystring is a list of parameter name and its value. Please google "querystring" for more information. The parameters you should use are the ones expected by the server. You have to ask the server creator about which parameters to send.
3) As I mentioned above, this doesn't make sense.
Hope this helps.
Since you likely have recorded this conversation, the natural question to ask why you would want to alter the request method in your application code to something else other than what is deployed? This is a break in your test between deployed and test and would need to be noted with your test results.
Requests' method should either POST or GET or other types of methods. There should NOT be both. I understand that you are doing self-study, but it is protocol violation.

Resources