Using Request Body in Azure Data Factory - rest

I have a working GET request in Postman where the body contains the query as seen below
The body is as follows
{
"query": {
"bool": {
"must": [
{
"term": {
"Vrvirksomhed.cvrNummer": "12345678"
}
}
]
}
}
}
Now i'm trying to get the same GET to work in Aure Data Factory but somehow it seems that the syntax needs to be different as it' doesn't use it correctly. Does it need to be wrapped somehow ?

This is because the ADF will ignore the Request body when your Request method is GET. So it can't work.
You can click '{}' button to view the code of Copy activity.
Even if your request body has content, there isn't requestBody property in source.
If you change your request method to POST, it will show.
So you can change your request method to POST to have a try.

Related

WooCommerce REST API PUT on Variations does not work

I have logged this issue on GitHub but I understand it will take time to get attention. Is there another way of updating Product Variations?
https://github.com/woocommerce/woocommerce/issues/35555
When I PUT a stock_quantity or price update for a product variation nothing changes. This however works 100% on a product but not a variation. The below will have no effect even though I receive an OK status 200.
PUT: wp-json/wc/v3/products/6360/variations/6361
{
"stock_quantity": 7
}
I also tried using the batch endpoint but also nothing gets updated.
/wp-json/wc/v3/products/6360/variations/batch
"update": [
{
"id":6361,
"stock_quantity": 4
}
]
This is not a bug, I was using Postman and the 200 OK returned confused the issue.
Once I added the required Content-Type:application/json header, the record successfully updated.
I also made use of a deprecated NodeJS library woocommerce-api and later tried with the replacement woocommerce-rest-api but both does not seem to handle this correctly.
I can suggest to rather just axios directly to the woocommerce rest api:
const baseUrl = `${process.env.WOOCOMMERCE_URI}/wp-json/wc/v3/`;
const instance = {
headers: {'Content-Type': 'application/json'},
auth: {
username: process.env.WOOCOMMERCE_KEY,
password: process.env.WOOCOMMERCE_SECRET
}
};
let putUrl = `products/${woocommerceImport.onlineProductId}/variations/${woocommerceImport.onlineVariantId}`;
await axios.put(`${baseUrl}${putUrl}`, {
stock_quantity: stock
}, instance);

JIRA trigger a workflow transition via REST

I want to trigger my test issue's current status, for example A to B via Rest call.
I've searched on the web and come across Atlassian Documentation. What it says:
->You must use POST method.
->You must define transition id in rest call body. Like following:
{
"update": {
"comment": [
{
"add": {
"body": "Aok was here"
}
}
]
},
"transitions": {
"id": "471"
}
}
->You must construct an url like: http://test/jira/rest/api/latest/issue/{ISSUE-KEY}/transitions
When i test above with post-man, i get nothing but a white page response body.
What may be wrong here?
Thanks
Anyone who faces this problem, here is the solution:
You need to make http request with Content-Type:application/json in header.

Elastic search - Unable to filter the JSON exact body using RestClient

Trying to query the exact JSON body by using Elastic search with RestClient API, but getting the whole body as response with hits,_source,etc.
So tried the filter_path [[filter_path=hits.hits._source]] approach in order to resolve this, but even that won't help to fetch exact body and coming with _source tag as mentioned below filter_path Response.
Can any one suggest please howt to get the exact json body as response like
{ "testAcct":"1234" }
Client.java:-
RestClient client = RestClient.builder(
new HttpHost(HOST, 9200, HTTP)).build();
Response response1 = client.performRequest("GET", SERVICE_URL + "_search",
Collections.<String, String>emptyMap(), new BasicHeader("testAcct", "1234"));
System.out.println(EntityUtils.toString(response1.getEntity()));
Response:-
{
"took":6,
"timed_out":false,
"_shards":{
"total":1,
"successful":1,
"failed":0
},
"hits":{
"total":21,
"max_score":1.0,
"hits":[
{
"_index":"testindex",
"_type":"testexternal",
"_id":"AVmHwA7Pkw5MudRUOp-q",
"_score":1.0,
"_source":{
"testAcct":"1234"
}
}
}
]
}
filter_path Response:-
{
"hits":{
"hits":[
{
"_source":{
"testAcct":"1234"
}
}
}
}

PUT Request not happening at all in Fantom

I am having some trouble with PUT requests to the google sheets api.
I have this code
spreadsheet_inputer := WebClient(`$google_sheet_URI_cells/R3C6?access_token=$accesstoken`)
xml_test := XDoc{
XElem("entry")
{
addAttr("xmlns","http://www.w3.org/2005/Atom")
addAttr("xmlns:gs","http://schemas.google.com/spreadsheets/2006")
XElem("id") { XText("https://spreadsheets.google.com/feeds/cells/$spreadsheet_id/1/private/full/R3C6?access_token=$accesstoken"), },
XElem("link") { addAttr("rel","edit");addAttr("type","application/atom+xml");addAttr("href","https://spreadsheets.google.com/feeds/cells/$spreadsheet_id/1/private/full/R3C6?access_token=$accesstoken"); },
XElem("gs:cell") { addAttr("row","3");addAttr("col","6");addAttr("inputValue","testing 123"); },
},
}
spreadsheet_inputer.reqHeaders["If-match"] = "*"
spreadsheet_inputer.reqHeaders["Content-Type"] = "application/atom+xml"
spreadsheet_inputer.reqMethod = "PUT"
spreadsheet_inputer.writeReq
spreadsheet_inputer.reqOut.writeXml(xml_test.writeToStr).close
echo(spreadsheet_inputer.resStr)
Right now it returns
sys::IOErr: No input stream for response 0
at the echo statement.
I have all the necessary data (at least i'm pretty sure) and it works here https://developers.google.com/oauthplayground/
Just to note, it does not accurately update the calendars.
EDIT: I had it return the response code and it was a 0, any pointers on what this means from the google sheets api? Or the fantom webclient?
WebClient.resCode is a non-nullable Int so it is 0 by default hence the problem would be either the request not being sent or the response not being read.
As you are obviously writing the request, the problem should the latter. Try calling WebClient.readRes() before resStr.
This readRes()
Read the response status line and response headers. This method may be called after the request has been written via writeReq and reqOut. Once this method completes the response status and headers are available. If there is a response body, it is available for reading via resIn. Throw IOErr if there is a network or protocol error. Return this.
Try this:
echo(spreadsheet_inputer.readRes.resStr)
I suspect the following line will also cause you problems:
spreadsheet_inputer.reqOut.writeXml(xml_test.writeToStr).close
becasue writeXml() escapes the string to be XML safe, whereas you'll want to just print the string. Try this:
spreadsheet_inputer.reqOut.writeChars(xml_test.writeToStr).close

How to handle json payload in GET request Play 2.0 + Scala

I want to make a handler/controller for a GET request such as in ElasticSearch :
$ curl -XGET 'http://localhost:9200/twitter/tweet/_search?routing=kimchy' -d '{
"query": {
"filtered" : {
"query" : {
"query_string" : {
"query" : "some query string here"
}
},
"filter" : {
"term" : { "user" : "kimchy" }
}
}
}}
I read the documentation from http://www.playframework.org/documentation/2.0.4/ScalaJsonRequests but the example is based on POST request. I've tried on my own it appears that I can access to the body request with POST request. But, when I try with the GET request, my request.body is AnyContentAsEmpty.
Is there a way to handle the json from this request in Play 2.0 ?
I saw that there is no body semantic for GET : Payloads of HTTP Request Methods .
So maybe it's normal that there is no mechanism to deal with it through Play 2.0.
I believe you are confused on what can you expect on each type of request. To sum it up:
GET requests contain the payload in the URL, no request body is
added
POST requests add the payload to the request body
From the example you post it seems that you want to return a Json answer as a result from a GET request, which would make more sense.
That can be easily achieved by crafting the Json string and using the Ok(result).as("application/json") to set the MIME type of the response.
this is a sample question
Play's default body parser follows the HTTP spec, and ignores the message body for GET, DELETE, HEAD and OPTIONS methods. If you want to force it to parse a body, you can do that by explicitly passing a body parser, eg:
def delete = Action(parse.json) { implicit request =>
val json = request.body
val someProp = (json \ "someprop").as[String]
Ok(s"Prop is: $someProp")
}