I need to get a bulk of issues that in the array of keys.
A GET URL-request like '...&issues in (key-1,key-2)...' is not an option for me because of length of the array may be more than 200 so it will be a 2000+ chars URL request and it is not good as I red here.
Here is Jira's API example but there is no comments about the jql property value format.
How should I fill the JSON-POST-model's jql property for get issues by keys?
You pass the jql as part of the request body. Here's a sample request body you can use for the /search endpoint using POST:
{
"jql": "status in (Done, \"in progress\") OR issue in (TEST-1, TEST-2) ORDER BY created"
}
Related
I want to know how can we create a REGEX to mask below value of content against Created By key in response received from REST API.
\\\"CreatedBy\\\":{\\\"content\\\":\\\"abcd#test.com\\\"}
So output which I am expecting is
\\\"CreatedBy\\\":{\\\"content\\\":\\\"****#****.***\\\"} OR
\\\"CreatedBy\\\":{\\\"content\\\":\\\"*************\\\"} which is getting logged in output logs.
The one which I created by taking reference of other
(?<=\\\\"CreatedBy\\\\": \s*{\\\\"content\\\\":\\\ "*)
but this is not working, can anybody help me on this
I have a JSON file in Azure Blob storage that I need to parse and insert rows into SQL using the Logic App.
I am using the "Get Blob Content" and my first attempt was to then pass to "Parse JSON". It returns and error": InvalidTemplate. Unable to process template language expressions in action 'Parse_JSON' inputs at line '1' and column '2856'"
I found some discussion that indicated that the content needs to be converted to a string so I used "Compose" and edited the code as suggested to
"inputs": "#base64ToString(body('Get_blob_content').$content)"
This works but then the InvalidTemplate issue gets pushed to the Parse function and I get the InvalidTemplate error there. I have tried wrapping the output in JSON expression and a few other things but I just can't get it to parse.
If I take a sample or even the entire JSON and put it into the INPUT of the Parse function it works without issue but it will not accept the blob content as JSON.
The only thing I have been able to do successfully from blob content is to take it as a string and update a row in SQL to later use the OPENJSON in SQL...but I run into an issue there that is for another post.
I am at a loss of what to do.
You don't post much information about your logic app actions, so maybe you could refer to my flow design. I test with a json data with array.
The below is my flow picture. I'm not using compose action, and use decodeBase64(body('Get_blob_content')['$content']) as the Parse Json content.
And if select property from the json, you need set the array index. I set a variable to get a value 'body('Parse_JSON')1['name']'.
you could have a try with this, if still fail, please provide more information or some sample to let us have a test.
Is it the recommended way to pass a JSON string as a parameter value in a REST API?
This is the data which I am trying to send :
http://127.0.0.1:8000/v1/product/?productName=&metrics={"memory":2,"disk_space":10}
Here, is it ok to pass the value of metrics as JSON value?
Initially, I tried passing the metrics JSON value in the body. As it is not supported/recommended standard I have removed it.
Is it the recommended way to pass a JSON string as a parameter value in a REST API?
REST is an architectural style and it doesn't enforce (or even define) any standards for passing JSON string as a parameter value.
If you want to send JSON in the query string, you must URL encode it first:
/v1/products?productName=&metrics=%7B%22memory%22%3A2%2C%22disk_space%22%3A10%7D
Alternativelly, you could redesign the parameters to be like:
/v1/products?productName=&metrics.memory=2&metrics.diskSpace=10
If the URL gets too long (or the query gets too complex to be expressed in the query string), you may want to consider POST instead of GET, and then send the JSON in the request payload:
POST /v1/products/search HTTP/1.1
Host: example.com
Content-Type: application/json
{
"productName": "foo",
"metrics": {
"memory": 2,
"diskSpace": 10
}
}
Sending JSON values in GET request is not recommended. You can do it but metrics json can be long and anybody can read the content.
You should use POST request to send parameters such as productName and metrics in the body.
You should refer to this answer for detailed explanation.
For use Content-Type Application Json Please use below line
request.AddParameter("application/json", "{\n\t\"lastName\":\"gaurav.sablok#agarwalpackers.com\"\n}", ParameterType.RequestBody);
This is used with "RestSharp" name spaces
Ok basically I am sending a POST request with some JSON payload in it to Codeigniter. I use RESTAdapater. JSON get sent there with no key, so I have no access to it.
Here is model:
App.Bookmark = DS.Model.extend({
title: DS.attr("string"),
url : DS.attr("string")
});
Here is controller:
App.BookmarksNewController = Ember.ObjectController.extend({
save: function(){
this.get("model.transaction").commit();
this.get("target").transitionTo("bookmarks");
}
});
In REST implementation in CI that I use standard way to access the post request is $this->input("key"). But when the above request is generated, only raw JSON data is sent. Therefore I don't seem to have a way to reference it in any way.
Take this example:
function post(){
$this->response(var_dump(file_get_contents("php://input")),200);
}
Gives me this output:
string(48) "{"bookmark":{"title":"sdffdfsd","url":"sdfsdf"}}"
what I would like to see is:
string(48) payload="{"bookmark":{"title":"sdffdfsd","url":"sdfsdf"}}"
Then is server I would be able to access this JSON with something like $this->post("payload").
So 1 of 2. Anyway to wrap the JSON payload with key? Or anyway to access raw JSON data in CI with no key available??
Ok figured it out myself (or rather read properly the examples).
When using Adam Whitney's fork of Phil Sturgeons REST controller for CodeIgniter the JSON payload will be available in $this->_post_args. And in the underlying implementation he uses my already mentioned file_get_contents("php://input").
EDIT: Same convention applies for other type of requests as well, for example DELETE request data will be available in $this->_delete_args. Or $this->_args is the "magic" place where all types of args can be found.
I have a "conceptual" question about designing a RESTful API which returns and accepts data in JSON format.
Consider following requests and responses:
GET http://host/records/12345
{ "id":"12345", "address":{"street":"main street","number":5,"city":"springfield"}}
GET http://host/records/12345/address
{"street":"main street","number":5,"city":"springfield"}
GET http://host/records/12345/address/city
{"city":"springfield"}
OR
springfield (=not valid json)
I realize that the second answer isn't a valid JSON response so I presume the latter is the correct answer to my question. However it looks redundant to me to respond in the form of a key/value since the requester already knew the "key" during the request.
Same counts for updates:
When I want to update the city of my 12345 record with another value what would be more correct to submit:
PUT http://host/records/12345/address/city
{"city":"paris"} <- content of body when submitting
OR
paris <- content of body when submitting (=not valid json)
The reason I'm asking is because one would already have enough by doing
PUT http://host/records/12345/address
{"city":"paris"} <- content of body when submitting
What would be considered to be most appropriate approach to this?
Thanks,
Jay
REST API's generally work on resources, which loosely translate to objects or tables in a database. Your first example of a GET does not indicate that you are trying to get a resource of type "address". What if you want to add additional resources to your API, for example "companies", then this would not be clear. And there should be a way to get a list of all of the addresses. So to get all of the addresses the API call would look like
GET http://host/records/address
[{"id":"12345", "street":"main street","number":5,"city":"springfield"},
{"id":"12346", "street":"foo street","number":1,"city":"alexandria"}]
To get a specific address it would look like
GET http://host/records/address/12345
{"id":"12345", "street":"main street","number":5,"city":"springfield"}
That id is part of the address object and I do not see any need to break it out into a parent object as in your example. You then use that id to let your web service know what needs to be updated. So your update would look like this.
PUT http://host/records/address
{"id":"12345", "street":"main street","number":5,"city":"paris"}
Usually the client would send the whole object over and not just the fields to update.
If you really want to do this "micro-PUT" style of updating then consider just sending the body using the text/plain media type. One of the beauties of using HTTP is that you can freely mix and match media types to use what is the most appropriate.
PUT http://host/records/12345/address/city
Content-Type: text/plain
Content-Length: 5
paris
=>
200 OK
Be warned though, HTTP is optimized for working with large grain resources. If you see your users wanting to do these kind of small updates frequently then maybe you need to reconsider the approach.