Closed EmilTemirov closed 9 years ago
You post any JSON data in the same format as we show for the response (i see the documentation needs to be improved on this).
The HTTP post would look something like this (some fields you see above are documented as read-only):
POST /api/responses HTTP/1.1
Host: api-sandbox.gresb.com
Accept: */*
Content-Type: application/json
{
"survey_date": 2015,
"name": "responseTest4",
"manager": null,
"legal_status": null,
"property_type": null,
"country": null
}
Which you could test with the curl
client like so (whitespace doesn't matter in JSON):
curl -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H "Content-Type: application/json" -d '{"survey_date": 2015, "name": "responseTest4", "m anager": null, "legal_status": null, "property_type": null, "country": null }' https://api-sandbox.gresb.com/api/responses
Request params can also be URL query params (which is much easier to do in many clients):
curl -H 'Authorization: Bearer ....' https://api-sandbox.gresb.com/api/responses?name=responseTest4&manager=foo
Finally they can be in the request body as application/x-www-form-urlencoded
or multipart/form-data
data. This is how HTML forms send data.
POST /api/responses HTTP/1.1
Host: api-sandbox.gresb.com
Accept: */*
Content-Type: application/x-www-form-urlencoded
name=responseTest4&manager=foo
I'm sorry if I made you confuse, but I posted request presented in HTTP Archive format or HAR. I tried to send request the same as you provided before via curl and got a problem that manager, property_type, country, legal_status values are not saved.
>> curl -H 'Authorization: Bearer MY_ACCESS_TOKEN' -H "Content-Type: application/json" -d '{"survey_date": 2015, "name": "responseCurl", "manager": "Emil", "legal_status": 1, "property_type": 2, "country": "GB" }' https://api-sandbox.gresb.com/api/responses
{
"country": null,
"created_at": "2015-03-18T16:44:25Z",
"id": 2676,
"legal_status": null,
"manager": null,
"name": "responseCurl",
"property_type": null,
"region": null,
"submitted_at": null,
"survey_date": "2015",
"updated_at": "2015-03-18T16:44:25Z"
}
I see now the issue. region, country, property_type, legal_status and survey_date were incorrectly documented as being optionally updatable. They are in-fact read-only and only set after a response has been submitted and scored. Documentation has been updated to reflect this correctly now: http://gresb.github.io/api-docs/#fields I hope it doesnt cause you too much trouble.
Also checkout the documentation version history which now says something useful: http://localhost:4567/#versioning
Make that http://gresb.github.io/api-docs/#versioning in my last comment :)
I try to create GRESB response by sending this request:
But I get response with name value only:
What is my mistake?