I have this: PUT/admin/orders/450789469/fulfillments/255858046.json in updating the fulfillment.
I have this following json data to update:
{ "fulfillment": {"id":3604167143,"order_id":4015640143,"status":"success","tracking_numbers":"6J700123456","variant_inventory_management":"shopify"}}
It returns a 400 error - Bad request.
Is there anything I've missed in passing the data to update? Thanks.
You'll want to send tracking_numbers as an array, rather than a string. Try something like this:
{
"fulfillment": {
"id": 3604167143,
"order_id": 4015640143,
"status": "success",
"tracking_numbers": ["6J700123456"],
"variant_inventory_management": "shopify"
}
}
If you look in the body of the response from Shopify then you can sometimes find more info about what went wrong.
Related
I'm trying to update the label in google contacts using the method from the docs
https://developers.google.com/people/api/rest/v1/contactGroups/update
Got a response
{
"error": {
"code": 400,
"message": "Fingerprint is missing.",
"status": "INVALID_ARGUMENT"
}
}
Even though Google API Explorer
How solve this, maybe someone can help. What does this Fingerprint mean? I can create/delete label but not update!
You have to include the etag.
If you go to Method: contactGroups.get or the Method: contactGroups.list, on the response you will find the groups 'etag'
Then on the Method: contactGroups.update request body you set the new name you want the group to have and also include the etag like this:
{
"contactGroup": {
"name": "newOne2",
"etag": "r*****k="
}
}
let me explain my problem
In my wordpress site I installed the WP REST API plugin to be able to read some listing fields via API
With postman if I use
GET https://mysitecom/wp-json/wp/v2/job-listings/1010
I get the following json correctly:
{
"id": 10565,
...
"status": "publish",
"type": "job_listing",
"title": "first try",
...
"_company_whatsapp": "",
"_company_mobile": "3331234567",
"_company_website": "",
"_company_use_social_networks": "",
"_company_facebook": "",
"_company_instagram": "",
...
}
If I want to edit 2 fields and use
PUT https://mysitecom/wp-json/wp/v2/job-listings/1010
with the following json:
{
"title": "edit try",
"_company_mobile": "3339999999",
}
It change the title but not the phone number.
If I try to change only the number with
{
"_company_mobile": "3339999999",
}
Postman returns this to me
{
"code": "rest_invalid_json",
"message": "JSON with invalid body was passed.",
"data": {
"status": 400,
"json_error_code": 4,
"json_error_message": "Syntax error"
}
}
I'm approaching the use of APi for the first time, what am I doing wrong? What is the problem and how can I fix it?
Thanks in advance
This json is invalid:
{
"_company_mobile": "3339999999",
}
You should remove the comma:
{
"_company_mobile": "3339999999"
}
Normally this is expected behaviour for PUT. You can skip fields only if they are optional. You cant pass only the field you want to update. Think of PUT like overwrite. The api applies the same validation like it will do for create (POST). Some APIs provide partial update with PATCH verb. Then you can provide only the fields you want to update usually as query params. Not sure what is exactly the case with Wordpress api.
If my response from my api looks like this.
{
"message": "The given data was invalid.",
"errors": {
"email": [
"The email has already been taken."
]
}
}
How can I get the first key in the errors in dart?
Currently I am doing
var body = json.decode(response.body);
print(body['errors']['email']);
But ['email'] could be dynamic, I just want whatever the first entry is of the errors
maybe you can try something like:
print(body['errors'].keys.toList()[0]);
I've got a API stage that's NOT using "Lambda Proxy integration" which has a Lambda function passing an error.
In the mapping template I have this:
$input.path("$.errorMessage")
Which results in the output of this:
{
"headers": {
"apiVersion": "20190218.1",
"isTesting": true
},
"body": {
"statusCode": 503,
"status": "Service Unavailable",
"title": "One or more of our data providers are currently offline for scheduled maintenance"
}
}
The header values are mapped to template headers and pull through correctly, however I need the body to transform to this:
{
"statusCode": 503,
"status": "Service Unavailable",
"title": "One or more of our data providers are currently offline for scheduled maintenance"
}
Whatever I have tried, body always returns as a blank string, an empty body, or an invalid JSON.
This is the closest I've got but it returns an invalid JSON:
$util.parseJson($input.path("$.errorMessage")).body
Result (comes back with no quotes):
{statusCode=503, status=Service Unavailable, title=One or more of our data providers are currently offline for scheduled maintenance}
Is it possible to do what I'm after? I can't find a reverse for $util.parseJson (i.e, stringify).
Thanks!
I think the original poster has probably moved on in the past 11 months, but in case anyone else stumbles across this question, $input.json('$.errorMessage.body') should work.
Anyone know of a way to send a JSON query to an ElasticSearch server via HTTP GET? I know you can POST the JSON content to _search, but POST is not available because this is cross-domain. For example, if my query looks like this:
{
"query": {
"query_string": {
"fields": ["name", "description"],
"query": "Elastic Search"
}
}
}
Which I would convert to something like:
{"query":{"query_string":{"fields":["name","description"],"query":"Elastic Search"}}}
Is there a way to GET server:9200/index/type/_search?content=stringifiedquery or something similar? I've tried q= and content= as well as just passing the content after the ? but nothing seems to work. Anyone have any ideas? Or am I just out of luck?
You can use the source query string parameter to send what would normally be the post body.
See the bottom of this page: http://www.elasticsearch.org/guide/reference/api/