How to get response headers in neo4j - apoc.load.jsonParams()? - rest

I have the following CQL apoc query in neo4j that works fine to get response payload from a rest GET request:
CALL apoc.load.jsonParams($uri, {Authorization: $Bearertoken}, null)
YIELD value
UNWIND value.items AS item
RETURN item
However, the uri uses pagenation and the next page uri is present in the response header. Therefore, I need a way to retrieve the response header along with the value. Please let me know if there is a way to do this.
Thanks in advance.

The apoc.load.jsonParams procedure does not support returning the response header.
You can write your own code instead. Here is an article that can help get you started.

Related

Is there a way to set headers for GET requests in KDB?

I'm trying to make get requested with .Q.hg (HTTP get), but I need to edit the request headers to provide API keys. How can I do this?
You can try this function I wrote a few years back for a POC (similar reason - I needed to supply multiple headers). It's based on .Q.hmb which underpins .Q.hp/hg. Please note - it was never extensively tested & there are likely better alternatives out there, but it will perhaps work as a quick solution.
k)req:{[url;method;hd;bd]d:s,s:"\r\n";url:$[10=#url;url;1_$url];p:{$[#y;y;x]}/getenv`$_:\("HTTP";"NO"),\:"_PROXY";u:.Q.hap#url;t:~(~#*p)||/(*":"\:u 2)like/:{(("."=*x)#"*"),x}'","\:p 1;a:$[t;p:.Q.hap#*p;u]1;(4+*r ss d)_r:(`$":",,/($[t;p;u]0 2))($method)," ",$[t;url;u 3]," HTTP/1.1",s,(s/:("Connection: close";"Host: ",u 2),((0<#a)#,$[t;"Proxy-";""],"Authorization: Basic ",.Q.btoa a),($[#hd;(!hd),'": ",/:. hd;()])),($[#bd;(s,"Content-length: ",$#bd),d,bd;d])}
It takes 4 arguments:
Resource URL
HTTP method
Dictionary of headers
Message body as JSON object
Sending a request to a test server..
q).j.k req["https://httpbin.org/get";`GET;("Content-Type";"someOtherHeader")!(.h.ty`json;"blah");""] // no body so pass empty string
args | (`symbol$())!()
headers| `Content-Type`Host`Someotherheader`X-Amzn-Trace-Id!("application/jso..
url | "https://httpbin.org/get"

Is there an option to remove the multipart content set in request in REST API(RestAssured) after getting a response?

In REST API, specifically RestAssured, there is an option to remove the Query params, Headers, Cookies, Form params, Path params which is set in request after getting a response.
Is there an option to remove the multipart content set in request in REST API(RestAssured) after getting a response?
If you're looking a way to reuse the RequestSpecification object, then No, there are no reset method for all of these config.
You can create new RequestSpecification object each time you call the request. Sample here. https://stackoverflow.com/a/69569031/7574461

How to extract response data in Gatling

I'm new with gatling and I have problem that I can't resolve by myself. I have to send request and after that I have to catch data from response. I can send request using get method, but I don't have idea how to extract data from response. Do you have any ideas how to do this? Thanks for your help.
I did this using check clause
http("Poll")
.get(Configuration.URL )
.queryParam("applicationId", Configuration.APPLICATION_ID)
.check(status.is(200))
.check(status.saveAs("statusCode"))
.check(xpath("//myRunTimeInfo").saveAs("runtimeInfoStatus"))
.check(xpath("//status").saveAs("responseStatus")))
.pause(Configuration.THINK_TIME second)
xpath : will do a search in your response using xpath specifications

POSTa Request with rest assured api using XML Payload

I am in need of one requirement.I want to POST a request using Rest Assured API using XML payload,I did not get any where how to set the body using XML. any one please tell me how I can achieve this.
I have one table customers with 5 fileds,name,id,address,email and phone number.My URL to post the request is something like
"http://com.myproject.app:8080/MyApp/SchmaName/customers".Please any one help me out.Thanks in advance
The above should work, here it is again in a slightly different version with your example...
Response response = given().
contentType("application/xml").
body(myXML).
when().
post("http://com.myproject.app:8080/MyApp/SchmaName/customers");
myXML would be the xml you want to send (5 fields; name,id,address,email and phone number). After that you can pull the result from response.
You can just post in the request body as a String, InputStream, byte[] or a Java object (that will be serialized to XML using JAXB). For example:
String myXML = ..
given().contentType(ContentType.XML).body(myXML).when().post("/x").then(). ..

Chrome Postman REST: reusing response values as request params in collections?

I'm playing around with Postman REST extension's collections feature.
I have 2 requests: the 1st returns a sessionId in its response body and the 2nd requires the {{sessionId}} value as query param. Can I tell Postman to save the body of the 1st response to the {{sessionId}} variable?
I currently have to a) execute 1st request and b) copy response body and paste it as a value of the 2nd request's query param every time...
thanks,
-nikita
Absolutely Yes!
Here is a json example:
I added the following to the Tests Tab of the first request:
var data = JSON.parse(responseBody);
postman.setGlobalVariable("session_id", data['session_id']);
Basically retrieving the data from responseBody and set it as a global variable
Then in the second request, the URL would be something like this:
http://{{whateverhost}}/api/v1/somefunction/{{session_id}}
Hope this helps.
Cheers