Making PUT and GET Responses in Katalon Studio - api

I’m new in working with RESTful APIs. For my case I want to make an PUT Request and then GET it.
I made an PUT Request and it worked. [1]: https://imgur.com/a/zlUTzYB
But now I want to make an GET Request. Can I somehow make so that GET Request will automatically take PUT Requests statementId and bind it to the link. [2]: https://imgur.com/a/qqBd5nR
I watched a lot of videos and documentations about APIs but still doens't get it how to make it. I’m really new for making such things and sorry if I asked a dumb question.

These steps might help to solve your case:
- Execute the PUT request
- Get the Response, parse it using Jsonslurper, and the the value out.
- Save the value into a variable, ie GlobalVariable
- Create the GET request with parameter taken from the GlobalVariable
- Execute the GET request.

Found an answer:
RequestObject ro = findTestObject("GET_request")
ro.setRestUrl(String.format(ro.getRestUrl(), idValue2))
ResponseObject resp = WS.sendRequest(ro)

Related

Unable to POST Multipart Form in Robot Framework Using Request Library

I have the following request in postman:
I have been using request library since the beginning automation on API: https://marketsquare.github.io/robotframework-requests/doc/RequestsLibrary.html#POST%20On%20Session
I tried to automate based on the postman request above with several trial and errors:
It always return 400 although the headers value set already correct:
What did I miss in the steps above?
Thank you in advance!
You should pass file descriptor not dictionary and "POST On Session" accepts file as "data" argument not "files". Try this
${file_stream} = Get File For Streaming Upload ${file_path}
${response} = POST On Session ${alias} ${URI} data=${file_stream}
On the second line you should add the rest arguments.
P.S. Next time please don't post code as screenshot, it makes hard for someone to copy and run it.
this is a false-negative due to the framework used by developers.
The developer has updated their framework and it works fine now.
No issues on the Robot Framework Request Library
Thank you.

Apache Nutch REST api

I'm trying to launch a crawl via the rest api. A crawl starts with injecting urls. Using a chrome developer tool "Advanced Rest Client" I'm trying to build this POST payload up but the response I get is a 400 Bad Request.
POST - http://localhost:8081/job/create
Payload
{
"crawl-id":"crawl-01",
"type":"INJECT",
"config-id":"default",
"args":{ "path/to/seedlist/directory"}
}
My problem is in the args, I think more is needed but I'm not sure. In the NutchRESTAPI page this is the sample it gives for creating a job.
POST /job/create
{
"crawlId":"crawl-01",
"type":"FETCH",
"confId":"default",
"args":{"someParam":"someValue"}
}
POST /job/create
{
"crawlId":"crawl-01",
"jobClassName":"org.apache.nutch.fetcher.FetcherJob"
"confId":"default",
"args":{"someParam":"someValue"}
}
I'm not sure what param or value to give each of the commands to complete a job. (eg. Inject, Generate, Fetch, Parse, and UpdateDb) Can someone clear this up? How do I tell the api where to look for the seedlist at?
UPDATE
When trying to complete the Generate command I came into a classException error where the value for the topN key is to be of type long but the api reads it as either a string or an int. I found a fix that is supposed to included in the 2.3.1 release (release date: TBA) and applied it and recompiled my code. It can now work.
At the time of this posting, the REST API is not yet complete. A much more detailed document exists, though it's still not comprehensive. It is linked to in the following email from the user mailing list (which you might want to consider joining):
http://www.mail-archive.com/user%40nutch.apache.org/msg13652.html
But to answer your question about the seedlist, you can create the seedlist through REST, or you can use the argument "seedDir"
{
"args":{
"seedDir":"/path/to/seed/directory"
},
"confId":"default",
"crawlId":"sample-crawl-01",
"type":"INJECT"
}

What could cause this API Get request to not work?

I am making a GET request to the following url:
http://testsurveys.com/surveys/demo-survey/?collector=10720
and the request works fine. The point is to assign collector ID 10720 to the survey. There is absolutely no issue with this request. However, when I add another parameter the collector ID is passed through as a get parameter but it does nothing. For example:
http://testsurveys.com/surveys/demo-survey/?code=123456&collector=10720
Why does the collector parameter work in the first scenario but not in the second?
That would depend on the code in your backend. There's nothing wrong with the second request. The fact that the parameters do get through to the other end is evidence of this. Try looking at your backend code and see why it isn't being processed properly. Were you coding it with any assumptions in mind that you ended up changing later? If you don't find anything, include the code in your question.

Use AWS S3 success_action_redirect policy with XHR

I'm using signed POST to upload file directly to amazon S3. I had some trouble with the signature of the policy using PHP but finally fixed it and here is the sample of code.
This xhr request is send in javascript and I'm waiting for an answer from amazon. At first I was using success_action_status setting it to 201 to get the XML response.
What I'd like to do is using the success_action_redirect to call a script on my server to create a record in the database.
The reason why is that I could create the record in the database and if anything wrong happen at this stage I can return an error message directly at this point. Also it saves me another ajax request to my server.
So I've tried to set this up specifying the success_action_redirect to http:\\localhost\callback.php where I have a script that is waiting for some parameters.
But it looks like this script is never called and the response of the xhr.send() is empty.
I think it's a cross-browser issue and I'm wondering if it would be possible to use jsonp somehow to pass-by this?
Any ideas?
UPDATE
Apparently xhr is following redirect natively so it should work but when I specified the success_action_redirect it returns error Server responded with 0 code.
At first I thought it was because the redirect URL was on my local server so I've changed it to an accessible server but no chance.
Anyone knows why it's returning this error message?
I also run into this problem. It seems like nobody has a solution to this like this
maybe the best workaround i have found is something like this.
It seems thet the only workaround includes a second xhr-request to execute the callback manually. therefore the
success_action_status
should be used. Witht his you will get a 201 response if the upload was successful and you can start a second request for the actual callback. For me it looks like the only possible solution at the moment.
Any other solutions?

Making Odata Saves without the response

Just wondering if there is anyway to save data across the line without the response coming back. i.e. Im using the objc odata sdk. If I create an employee entity on the ipad, than I save it, I dont need to receive the the saved entity back. So really its sending the data across the line than returning it for no reason. Only really need to send it across.
Any ideas on how I can set saves to be push to server and not have to wait for the return?
Thanks in advance
In the latest CTP (http://blogs.msdn.com/b/astoriateam/archive/2011/10/13/announcing-wcf-data-services-oct-2011-ctp-for-net-4-and-silverlight-4.aspx) you can use the Prefer header. The client can send the request with Prefer header set to return-no-content and the server will send an empty response back. The header is described here: https://datatracker.ietf.org/doc/html/draft-snell-http-prefer-01.