The following HTTP request was sent and an HTTP 400 response was received. What is wrong with the request that caused it to fail?
POST /api/v2/organizations/4523jddfgd/projects HTTP/1.1
Host: www.reddit.com
Content-Type: application/json
Authorization: Bearer VALID_API_TOKEN
[
"name": "Project 1",
"package": "Standard",
"address": {
"street": "12456 Main St",
"city": "Dallas",
"zip": "75200",
"state": "TX",
"country": "USA"
}
]
This is an interview question, can you help guys ?
Have a look at the MDN wiki page about HTML status code 400.
Status code 400 points to a client side error e.g. malformed request body. Another reason could be that a required header is missing. As indicated in the MDN wiki page you should not attempt to send the very same request unmodified again as the result will be the same as it is not a server side issue.
What you should do instead is: consult the API documentation again and make sure that no header is missing and the request body is valid (i.e. valid JSON/ XML/ whatever in the correct structure).
Looking at your request I can see that the body is not valid JSON.
[
"name": "Project 1",
"package": "Standard",
"address": {
"street": "12456 Main St",
"city": "Dallas",
"zip": "75200",
"state": "TX",
"country": "USA"
}
]
This cannot be parsed, hence the error. An array cannot hold properties. What is missing is a { and } after the [ and before the closing ].
Using the following request body should work.
[
{
"name":"Project 1",
"package":"Standard",
"address":{
"street":"12456 Main St",
"city":"Dallas",
"zip":"75200",
"state":"TX",
"country":"USA"
}
}
]
EDIT
As #Evert pointed out, it is more likely that you need to replace [] with {} as POST requests are used to create single new resources. But the only way you can be absolutely sure is by reading the API documentation.
{
"name":"Project 1",
"package":"Standard",
"address":{
"street":"12456 Main St",
"city":"Dallas",
"zip":"75200",
"state":"TX",
"country":"USA"
}
}
Related
Trying to migrate our calls away from the v2/ugcPosts endpoint to the new /rest/posts endpoint. I started off trying to create a text-only post as per the Text-Only Post Creation Sample Request
I copied and pasted the request body, changed the organization ID to my own, and included Authorization: Bearer {My Authorization Token}, X-Restli-Protocol-Version: 2.0.0, Content-Type: application/json, LinkedIn-Version:202207 as headers.
POST https://api.linkedin.com/rest/posts
{
"author": "urn:li:organization:***",
"commentary": "Sample text Post",
"visibility": "PUBLIC",
"distribution": {
"feedDistribution": "NONE",
"targetEntities": [],
"thirdPartyDistributionChannels": []
},
"lifecycleState": "PUBLISHED",
"isReshareDisabledByAuthor": false
}
However, when trying to post, I keep getting this 400 error.
{
"errorDetailType": "com.linkedin.common.error.BadRequest",
"code": "MISSING_REQUIRED_FIELD_FOR_DSC",
"message": "Field /adContext/dscAdAccount is required when the post is a Direct Sponsored Content, but missing in the request",
"errorDetails": {
"inputErrors": [
{
"description": "Field /adContext/dscAdAccount is required when the post is a Direct Sponsored Content, but missing in the request",
"input": {
"inputPath": {
"fieldPath": "/adContext/dscAdAccount"
}
},
"code": "MISSING_REQUIRED_FIELD_FOR_DSC"
}
]
},
"status": 400
}
I see that lifecycleState, distribution, visibility, commentary, author are all required, but adContext should be an optional field. I'm not sure what part of my request is indicating I'm trying to make a Direct Sponsored Content post - can someone take a look?
I've already tried
Removing the targetEntities and thirdPartyDistributionChannels parameters.
Removing isReshareDisabledByAuthor and the above.
Changing the feedDistribution to MAIN_FEED and NONE
Creating the post via the /v2/ugcPosts endpoint - meaning the authorization token and organization urn are correct
The response from HERE's /autosuggest endpoint has unexpected element in it.
When making a request to Here autosuggest endpoint like: https://places.cit.api.here.com/places/v1/autosuggest?at=51.73771300000001,19.454722&q=wlokniarzy 91&maxresults=10&language=sv&additionaldata=Country2,true&cs=pds&result_types=address,place&addressFilter=countryCode=POL
In the response third element looks like:
{
"title": "91",
"highlightedTitle": "<b>91</b>",
"vicinity": "92-432 Lodz",
"highlightedVicinity": "92-432 Lodz",
"position": [
51.79221,
19.42193
],
"category": "900-9400-0401",
"categoryTitle": "Street or Square",
"bbox": [
19.421049,
51.791988,
19.422041,
51.792599
],
"type": "urn:nlp-types:place",
"resultType": "address",
}
Which I think should not show up looking like that.
It hard to even guess what this place suppose to be.
Is it a bug in Here autosuggest endpoint?
We will take a look at the place, and the place should be removed from Place API.
Thank you for the report!
I've suddenly recently started seeing errors like "Failed to parse Dialogflow response into AppResponse : null" on Actions On Google/Dialogflow projects that previously worked ok.
Even now, the error seems intermittent, and happens despite the response from my Firebase function (fulfilment webhook) being identical. In other words, sometimes I get the above error, and other times it works, but the response from my Firebase function is identical in both cases.
As an example, here is a response that sometimes, but not always, causes the error I mention above:
{ "status": 200, "headers": { "content-type":
"application/json;charset=utf-8" }, "body": { "payload": { "google": {
"expectUserResponse": true, "systemIntent": { "intent":
"actions.intent.OPTION", "data": { "#type":
"type.googleapis.com/google.actions.v2.OptionValueSpec", "listSelect":
{ "title": "Please select one option:", "items": [ { "optionInfo": {
"key": "Yes", "synonyms": [ [ "Go", "Lets go", "Let's go", "Get
started", "Yes", "I am ready", "Start the survey", "Start", "1", "One"
] ] }, "description": " Start a new diary entry", "title": "1. Let's
Go" }, { "optionInfo": { "key": "Stop", "synonyms": [ [ "No", "Don't
continue", "No thanks", "Stop", "Stop the survey", "2", "Two" ] ] },
"description": " Don't make a new diary entry", "title": "1. Stop" } ]
} } }, "richResponse": { "items": [ { "simpleResponse": {
"textToSpeech": "Hi. It’s
nice to have you here and we look forward to discussing the food and
drink you give your baby.Let us know each time
you give them something to eat or drink.When you
are ready to start, say Let’s go.", "displayText":
"Hi. \n \nLet us know each time you give them something to eat or
drink. \n \nWhen you are ready to start, select Let’s go." } } ] },
"userStorage":
"{\"data\":{\"userId\":\"bb46f3f9-e522-2da0-7b3c-302a615d28e4\",\"unicomId\":\"danone2\"}}"
} } } }
So in the Firebase logs I can see the above being returned in all cases, but sometimes Google Assistant fails, and the Google Cloud logs show the "Failed to parse Dialogflow response into AppResponse : null" error, and other times, with the identical JSON returned by Firebase, it happily works.
I'm at a slight loss as to where to look further, if anyone has any pointers that'd be much appreciated, thanks!
I had a same problem. In my case, systemIntent in my response json was null and it caused this error. It worked fine before but recently It failed. I hope it helps someone.
Just to close this issue - turns out this was my fault, and the JSON response was contructed wrongly (the "synonyms" were enclosed in duplicate [[ and ]]). I believe Dialogflow was suddenly flagging this as an error, when previously it was more forgiving.
Anyway - fixing the JSON response has fixed the issue.
In the RingCentral Online Account Portal (https://service.ringcentral.com) and endpoint apps, the call log display shows whether a call was Inbound, Outbound or Missed.
In looking at the API Reference for the Call Log API, it seems that it only sends back Inbound or Outbound for "Direction". Does the developer Call Log API return a "Missed" value? Is there another way to get this information via the Call Log API?
Ref: https://developer.ringcentral.com/api-docs/latest/index.html#!#RefCallLog.html
This question appears to be in reference to the Online Account Portal UI's "Type" column as shown in this screenshot:
The web UI's "Type" column shows Inbound, Outbound or Missed. This can be generated by using the response properties for both direction and result.
direction API response property will be Inbound or Outbound
result API response property is an enumerated value that includes Missed and other values including Voicemail which is the example screenshot. A full list is available in the link below:
Ref: https://developer.ringcentral.com/api-docs/latest/index.html#!#ResultStatusValues
Here is an example response:
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/call-log?view=Simple&showBlocked=true&withRecording=false&dateFrom=2018-08-27T06:18:00.000Z&page=1&perPage=100",
"records": [
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/call-log/22222222?view=Simple",
"id": "22222222",
"sessionId": "33333333",
"startTime": "2018-08-27T17:38:12.634Z",
"duration": 27,
"type": "Voice",
"direction": "Inbound",
"action": "Phone Call",
"result": "Missed",
"to": {
"phoneNumber": "+16505550101"
},
"from": {
"phoneNumber": "+16505550102",
"name": "LOS ALTOS CA",
"location": "Los Altos, CA"
}
}
],
...
}
Please read this blog to find out more information you can find from the call log.
I'm trying to remove some attendees from a Google Calendar Event, which relates to a room resource calendar, while using the tool on the API documentation Try It API Explorer, properly authorized using a domain admin account which has admin rights over that calendar,
I'm sending a request body deleting two attendees from the event, the API results is 200 OK, but the attendees remains there..
I've tried to add a new attendee or updating it's status and it works ok, but not for removing the attendee..
Any body know what I'm missing here? I've also tried using this through GAS and I'm experiencing the same issue, but to discard any self programming issue I've tried with the official API Try It tool
Request
PATCH
https://www.googleapis.com/calendar/v3/calendars/supportworld.com.ar_34373XXXXXXXXXXX2%40resource.calendar.google.com/events/osrd3lXXXXXXXolks?fields=attendees%2Cid&key={YOUR_API_KEY}
Content-Type: application/json
Authorization: Bearer ya29.bwAXXXXXXXXJOeCUAAADDYWT-QXXXXXXXXXXrc_eGP6Lk7CXXXXXXXXJ6130__ci_-_YXXXXxs
X-JavaScript-User-Agent: Google APIs Explorer
{
"attendees": [
{
"organizer": true,
"email": "xxxxx#netuxxxxxxrp.com",
"responseStatus": "accepted",
"displayName": "AAAAAAA"
},
{
"self": true,
"resource": true,
"email": "supportworld.com.ar_34373XXXXXXXXXXX2#resource.calendar.google.com",
"responseStatus": "accepted",
"displayName": "Cafetera"
}
],
"id": "osrd3lXXXXXXXolks
"
}
Response
200 OK
cache-control: no-cache, no-store, max-age=0, must-revalidate
content-encoding: gzip
content-length: 294
content-type: application/json; charset=UTF-8
date: Thu, 28 Aug 2014 16:15:06 GMT
etag: "XXXXXXXXX"
expires: Fri, 01 Jan 1990 00:00:00 GMT
pragma: no-cache
server: GSE
{
"id": "osrd3lids0gkoeaggp2c95olks",
"attendees": [
{
"email": "xxxxx#netuxxxxxxrp.com",
"displayName": "AAAAAAA",
"organizer": true,
"responseStatus": "accepted"
},
{
"email": "yyyyy#netuxxxxxxrp.com",
"displayName": "YYYYYYY",
"responseStatus": "accepted"
},
{
"email": "zzzzz#netuxxxxxxrp.com",
"displayName": "BBBBBB",
"responseStatus": "needsAction"
},
{
"email": "supportworld.com.ar_34373XXXXXXXXXXX2#resource.calendar.google.com",
"displayName": "Cafetera",
"self": true,
"resource": true,
"responseStatus": "accepted"
}
]
}
the entries:
{
"email": "yyyyy#netuxxxxxxrp.com",
"displayName": "YYYYYYY",
"responseStatus": "accepted"
},
{
"email": "zzzzz#netuxxxxxxrp.com",
"displayName": "BBBBBB",
"responseStatus": "needsAction"
}
shouldn't be there any more, but they are.. any help on this appreciated,
I was able to get it to work. I think there's an issue with the API explorer tool.
Specifically, where you specify the patch body, there's a structured editor through which you can add and remove sections of the JSON for the attendees object. When I removed an attendee from the list using the structured editor, and then switched over to the freeform editor, the attendee was still there. Bug!
Staying in the freeform editor, I removed the desired attendee block again and executed, and everything worked the way it should. I verified in a separate tab with a GET that the attendee was indeed removed.
(To get to the different editors, there is a drop down button in the top right of the patch body text field.)
I have got it working in C#, I think in other languages it will work the same way.
When I tried to remove the unwanted attendee from the list, it did not work.
eventItem.Attendees.Remove(new EventAttendee { Email = "<to be removed>#gmail.com" });
I imagine you have got to this point.
But when I replaced the list with another list without the attendee, it worked and the other attendees were not even notified about any changes.
eventItem.Attendees = eventItem.Attendees.Where(a => a.Email != "<to be removed>#gmail.com").ToList();
and of course a patch / update afterwards.
service.Events.Patch(eventItem, "primary", eventItem.Id).Execute();