Hi I have this cURL request that I have been trying and failing to get it right, it gives me a 500 Error (Internal Error)
Please see my curl request below:
curl --location --request POST "https://api.monday.com/v2" --header "Authorization: XXXXX" --header "Content-Type: application/json" --data-raw "{\"query\":\"mutation { create_item (board_id: 1622487816,group_id: \"emailed_items\", item_name: \"Test from Curl\") { id } }\"}" -v
I get back an empty object as a response but on the response header I see a 500 error message
Make sure your quotes are nested and escaped properly.
Your code:
"{\"query\":\"mutation { create_item (board_id: 1622487816,group_id: \"emailed_items\", item_name: \"Test from Curl\") { id } }\"}"
You are right to begin with a double quote and you are right to escape the first set of quotes within those quotes.
However, when you get further in the query, "emailed_items" also needs to be escaped, but since you are already in a set of quotes, you actually need three backslashes.
Corrected code:
"{\"query\":\"mutation { create_item (board_id: 1622487816,group_id: \\\"emailed_items\\\", item_name: \\\"Test from Curl\\\") { id } }\"}"
Make use of the npm package for monday.com queries. One such package is monday-sdk-js
Assigning parameters could be confusing thus make use of this package which takes query as a parameter and makes things easy.
Related
Using this link: https://learn.microsoft.com/en-us/azure/cognitive-services/form-recognizer/quickstarts/curl-train-extract I follow each step and use the sample data in the guide. All of them are successful until the last step which is "Get the Analyze results", where it returns the following:
{
"status": "failed",
"createdDateTime": "2020-07-09T14:59:12Z",
"lastUpdatedDateTime": "2020-07-09T14:59:14Z",
"analyzeResult": {
"version": null,
"readResults": null,
"pageResults": null,
"documentResults": null,
"errors": [
{
"code": "2003",
"message": "Download failed. Please check your input URL."
}
]
}
}
Unfortunately, there are no references to error codes and possible explanation/solutions. Assistance is highly appreciated.
The error message is quite clear: the url that you provided for the analysis does not allow the service to download the document.
Please check the content that you sent during the operation called "Analyze forms for key-value pairs and tables":
curl -v "https://<Endpoint>/formrecognizer/v2.0/custom/models/<model ID>/analyze" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: <subscription key>" -d "{ \"source\": \""<SAS URL>"\" } "
In particular, can you detail the last part? The piece with the '' block is the one causing the error
I am new to this topic and reviewed several SO answers before, but still cannot figure it out.
Trying to access API, using R:
curl -X POST "http://api.spending.gov.ua/api/rest/1.0/transactions" -H "accept: application/json" -H
"Content-Type: application/json" -d "{ \"payers_edrpous\": [ \"string\" ], \"recipt_edrpous\": [
\"string\" ], \"startdate\": \"string\", \"enddate\": \"string\", \"regions\": [ 0 ]}"
My current stage
library(httr)
r <- GET("http://api.spending.gov.ua/api/rest/1.0/transactions")
status_code(r)
This works, I have 200 response.
But how to write a query to get data in json format? Appreciate any tips.
The link from #dcruvolo was helpful.
In order get to this to work, you need to start with some valid values. From the API link in the question, there is a test page to order to test the submittal:
One can substitute in test values and then press the "Execute" button submit values. Attempted values from the comments above, valid enough not to cause an error but also did not return any valid results.
To perform the POST in R here is an example:
posting<-'{
"payers_edrpous": [
"00013534"
],
"recipt_edrpous": [
""
],
"startdate": "2020-03-01",
"enddate": "2020-03-28",
"regions": [
0
]
}'
library(httr)
r <- POST("http://api.spending.gov.ua/api/rest/1.0/transactions", body=posting,
httr::add_headers(`accept` = 'application/json'),
httr::content_type('application/json')) #encode="json"
content(r)
Posting is the JSON body to pass, edit this as necessary. All variables are strings except "regions" where it is an integer, not sure what the valid range is.
Sorry this is the best I can do. Good luck.
I have some problem with the "Find Entities by URNs" API in order to retrieve the metadata and value information for a collection of URNs.
If I use the URL described in the doc (Sample request) with a valid access token:
https://api.linkedin.com/v2/adTargetingEntities?q=urns&urns=List(urn%3Ali%3AfieldOfStudy%3A100990,urn%3Ali%3Aorganization%3A1035,urn%3Ali%3Aseniority%3A9)&locale=(language:en,country:US)&oauth2_access_token=<a-valid-token>
I receive the message:
{
"serviceErrorCode": 0,
"message": "java.lang.ClassCastException",
"status": 500
}
Anyone have experience the same issue? Any idea how to fix it?
Also: how can i contact for technical support as in this case?
UPDATE:
I made some try and I fix using the following version:
https://api.linkedin.com/v2/adTargetingEntities?q=urns&urns=urn%3Ali%3AfieldOfStudy%3A100990&urns=urn%3Ali%3Aorganization%3A1035&urns=urn%3Ali%3Aseniority%3A9&locale.language=it&locale.country=IT&oauth2_access_token=<a-valid-token>
BUT the locale/language translation is not working. Could be this a working solutions?
From the support team:
Our docs are missing 1 critical piece of information. Whenever using
LIST and encoded URNs in the URL, we expect an additional header 'x-restli-protocol-version: 2.0.0'
The correct API call would be Request:
curl -X GET \
'https://api.linkedin.com/v2/adTargetingEntities?q=urns&urns=List(urn%3Ali%3Aindustry%3A1,urn%3Ali%3Aseniority%3A9)&locale=(language:it,country:IT)'
\
-H 'x-restli-protocol-version: 2.0.0' \
-H 'Authorization: Bearer <Token>'
Response:
{
"elements": [
{
"facetUrn": "urn:li:adTargetingFacet:industries",
"name": "Difesa e spazio",
"urn": "urn:li:industry:1"
},
{
"facetUrn": "urn:li:adTargetingFacet:seniorities",
"name": "Partner",
"urn": "urn:li:seniority:9"
}
],
"paging": {
"count": 2147483647,
"links": [],
"start": 0
}
}
Yes, it does provide a response in locale.
Hope this can help other guys in the future
Im trying to perform PATCH Opeartion in cloud firestore using REST API.
This is my Request body
`{
"fields": {
"name": {
"stringValue":"Dinesh"
}
}
}`
When i fire the request , All the existing fields inside the document are getting deleted and only the name field is getting updated. In the Documentation they have given the Document Mask. but i dont understand how it works , neither im able to find any samples for that. Somebody know how to update only one field inside the document without affecting other fields ?
Without a DocumentMask object, the patch method defaults to replacing the Firestore Document with the request body rather than updating the submitted fields and retaining omitted fields.
The DocumentMask is submitted as an updateMask parameter containing the fieldPaths to be patched. It took a while but thanks to this answer and a lot of attempts I figured out that each fieldPath property of the updateMask object needs to be individually included in the query string of the request url:
https://firestore.googleapis.com/v1beta1/projects/{projectId}/databases/{databaseId}/documents/{document_path}?updateMask.fieldPaths=status&updateMask.fieldPaths=title
Where status and title are two fields in the request body. Note that fields included in the request body are disregarded if they are omitted from the query string, remaining unchanged.
Here is another example giving this json structure from firestore
"fields": {
"eth0": {
"mapValue": {
"fields": {
"address": {
"stringValue": "172.0.0.1"
},
"port": {
"stringValue": "8080"
},
"endpoint": {
"stringValue": "10.0.5.24"
}
}
}
}
}
Then to update the endpoint field only
curl -sSLX PATCH \
-H "Authorization: Bearer {TOKEN}" \
-H "Content-type: application/json" \
-d "{
\"fields\": {
\"eth0\": {
\"mapValue\": {
\"fields\": {
\"endpoint\": {
\"stringValue\": \"10.10.2.24\"
}
}
}
}
}
}" \
"https://firestore.googleapis.com/v1/projects/{project-id}/databases/(default)/documents/{collection}/{document}?updateMask.fieldPaths=eth0.endpoint")
Your request body is ok. But you need to use the update mask.
From reading the documents I found that the DocumentMask is used to restrict a get or update operation on a document to a subset of its fields. So by adding 'name' to your field paths on the mask, it will only allow you to update that specific field and the others won't get deleted.
You can read more about it here.
This curl call works to create a new droplet on Digital Ocean
curl -X POST "https://api.digitalocean.com/v2/droplets" \
-d '{"name":"test3","region":"nyc2","size":"512mb","image":5562742,"ssh_keys":[89103]}' \
-H "Authorization: Bearer $TOKEN"
-H "Content-Type: application/json"
However, I'm having trouble getting an httr::POST() request to work only when the parameter ssh_keys is given. In the above method the ssh_keys parameter, if given, has to be an array.
I assumed the list of parameters could be passed to the body as, e.g., where the ssh_keys parameter is inside a list
args <- list(name="test3", region="nyc2", size="512mb", image="5562742", ssh_keys=list(891111))
POST(url, config=auth, body=args)
I assume this is what's happening on the inside:
jsonlite::toJSON(args)
[1] "{ \"name\" : [ \"test3\" ], \"region\" : [ \"nyc2\" ], \"size\" : [ \"512mb\" ], \"image\" : [ \"5562742\" ], \"ssh_keys\" : [ [ 89103 ] ] }"
Which I imagine would work, but perhaps that's not what's happening? Fiddling with the encode parameter in POST doesn't seem to help.
The curl call works from terminal, but using httr::POST() I keep getting the error message
You specified invalid ssh key ids for Droplet creation.
In this specific case,
x <- jsonlite::toJSON(args, auto_unbox=TRUE)
cat(x)
seems to return the correct format (assuming the problem is not with the headers) so them
POST(url, config=auth, body=x)
should send the correct request.
Maybe something like:
req <- POST(
url = "https://api.digitalocean.com/v2/droplets",
body = toJSON(args, auto_unbox=TRUE),
add_headers (
"Content-Type" = "application/json",
"Authorization" = paste("Bearker", TOKEN)
)
)