Salta al contenuto principale

API v2 - Problem while updating Tenant with PUT method. Same problem while PUTting offering items with quotas

Thread solved
Messaggi: 10
Commenti: 8

While trying to update a Customer Tenant, I'm getting three different errors depending on the value set in the version field. The Customer Tenant I'm trying to update has these values (obtained by GET method on /api/2/tenants/6a525ab9-22bb-4597-9214-d83850433f61)

{"statusCode":200,"data":{"kind":"customer","language":"en_US","customer_id":null,"enabled":true,"parent_id":"55bbad2b-9664-4289-a526-ab20ce06ba6d","version":2,"internal_tag":null,"brand_id":1,"contact":{"firstname":"","phone":null,"email":"","address1":null,"country":null,"city":null,"address2":null,"lastname":"","state":null,"zipcode":null},"default_idp_id":"11111111-1111-1111-1111-111111111111","customer_type":"default","id":"6a525ab9-22bb-4597-9214-d83850433f61","owner_id":null,"has_children":false,"name":"Customer 03 API"}}

I've tried a PUT with the next request body:

{"id":"6a525ab9-22bb-4597-9214-d83850433f61","parent_id":"55bbad2b-9664-4289-a526-ab20ce06ba6d","brand_id":"1","default_idp_id":"11111111-1111-1111-1111-111111111111","name":"Customer  03 API","kind":"customer","language":"es_ES","version":3,"contact":{"firstname":"Customer  3","lastname":"APITest","email":"test@none.fake"}}

As can be seen, I incremented the version by one, but the Acronis platform returned a 409 error:

{"statusCode":409,"error":{"message":"The information about this object has been updated in another session. Please refresh the page.","code":1001},"data":null}

Then I tried leaving the version as it was, with value 2, but the Acronis platform failed with a 500 error:

{"statusCode":500,"error":{"message":"Internal Server Error","code":500},"data":null}

I also tried sending a Tenant PUT request without a version field,and what I've got then was a 400 error:

{"statusCode":400,"error":{"message":"Bad Request","code":400},"data":null}

And finally, I've tried sending a milliseconds timestamp as version (something like "version":1532934981), but again the Acronis server returned a 409 error:

So, what's the proper way to update a Tenant's data with the API v2?

*** Update 1 ***

While trying to PUT offering items into an application, the 409 error happens but this time I understand is related to the quota's version. Therefore, I must also ask what's the proper way to PUT offering items with quotas using the API v2?

0 Users found this helpful
Messaggi: 10
Commenti: 8

While testing, I've discovered how the PUT method works for tenants and for quotas in offering items.

  • In both cases, the CURRENT version value of the entity has to be sent with the updated data in the request. The Acronis Data Cloud takes care of increasing the version. This implies that, to update entities which also have a version attached to them, you have to get the current version first to send it back.
  • For tenants, the "kind" parameter CANNOT be sent, even if it has the same value as stored in the Acronis Data Cloud. Sending it in a tenant PUT request results in a 500 Internal Server Error.
  • Also, for offering items that are of the type "infra", the parameter "infra_id" has also to be sent in the PUT request. If not, the server reponses a 404 error with no body but with the reason phrase "Offering item \"{}\" is not available.".

None of this is specified in the available documentation, but I leave it here for future reference. With all this, I consider this topic solved.