GRESB / api-docs

http://gresb.github.io/api-docs/
3 stars 0 forks source link

Updating aseet data via API on test sandbox environment #29

Closed NehalJ closed 8 years ago

NehalJ commented 8 years ago

Hi,

I am updating data in GRESB sandbox environment, it returns below error.

The remote server returned an error: (500) Internal Server Error.

I am using below code to upload the data using c# 4.0 in asp.net.

client3.Headers[HttpRequestHeader.ContentType] = "application/json"; client3.UploadString("https://api-sandbox.gresb.com/api/responses/" + response_id + "/asset_level_data?access_token=" + access_token, "POST", s1.ToString())

S1.ToString() = {"buildings":[{"partners_id":"123456790","survey_data":{"2015":{"en_man_bse_abs":14835.18}}}]}

Regards,

amichal commented 8 years ago

I found the error in the server logs for this but it has no backtrace, wasn't reported to our exception notifier and is surrounded by other successful requests. Seeing if i can reproduce it now or track down what happened

amichal commented 8 years ago

ok.. found the problem for a 2015 survey you want to provide survey_data for '2014' and/or '2013' not '2015': see http://gresb.github.io/api-docs/#createupdate-asset-data-set.

Obviously this should not result in a 500 error. That we need to fix. What you should have received was 201 created but indicating a validation error with the survey data

{
  "id": 45,
  "oauth_application_id": 58,
  "created_at": "2015-10-15T17:55:36Z",
  "updated_at": "2015-10-15T17:55:36Z",
  "errors": {},
  "buildings": [
    {
      "created_at": "2015-10-15T17:55:38Z",
      "updated_at": "2015-10-15T17:55:38Z",
      "asset_name": null,
      "asset_country": null,
      "asset_address": null,
      "asset_size": null,
      "partners_id": "123456790",
      "property_type": null,
      "major_renovation": null,
      "survey_data": {
        "2014": {
          "errors": {
          }
        },
        "2013": {
          "errors": {
          }
        }
      },
      "errors": {"survey_data":["inclusion"]}
    }
  ]
}
amichal commented 8 years ago

@NehalJ: You should now receive the error shown above for your original query. Changing the data to 2014 will cause the update to actually succeed.

amichal commented 8 years ago

Please re-open this issue of you have further questions

amichal commented 8 years ago

I have added the case you described above to our test coverage