PUT Request Returning 409 Error

PUT Request Returning 409 Error

Anonymous
Not applicable
646 Views
2 Replies
Message 1 of 3

PUT Request Returning 409 Error

Anonymous
Not applicable

I am trying to perform a PUT request to update a workspace item. I used the method call:

 

var request = new RestRequest("/api/rest/v1/workspaces/" + workspaceID + "/items/" + projectID, Method.PUT);

and created an object to add to the request body:

 

 Rootobject root = new Rootobject
            {
                metaFields = new Metafields
                {
                    entry = new List<Entry>()
                }
            };

Then set the entry fields with key value pairs, and the version number of the root object. I got back this 409 error:

 

{"httpStatusCode":409,"error":[{"message":"The data you are attempting to edit has since been modified by another user, for details see the Change Log. You may attempt to perform your modification again."}]}

And can't find any documentation on what may be the problem. Any help would be appreciated!

 

 

 

 

 

0 Likes
647 Views
2 Replies
Replies (2)
Message 2 of 3

tony.mandatori
Autodesk
Autodesk

409 means that the server thinks the request cannot be completed because if conflicts with some established rule, in this case the server is saying that the object has been concurrently updated (which I don't think is the case).

 

I think that the payload is incorrect.  From the help, the request should look like this:

 

'{
    "versionID":0,
    "metaFields":{
        "entry": [ 
            {"key": "INSPECTION_TYPE", "value": "5"},
            {"key": "INSPECTED_BY", "value": "1"},
            {"key": "INSPECTED_ITEM", "value": "249"}
            ]
    }
}'

 

Perform a get and then try to reuse that payload to perform the update.

 

I have tried the following with a PUT and I get a 204 back (no content but the update works) - 

https://adskmandatt.autodeskplm360.net/api/rest/v1/workspaces/64/items/7797

 

{
    "versionID":0,
    "metaFields":{
        "entry": [ 
            {"key": "DESCRIPTION", "value": "Sample4"}
            ]
    }
}

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

Here was the problem:

 

We weren't copying the versionID when doing the PUT.  I still don't understand the reasoning behind this field, but it works now.  When copying the versionID, we got a 500 error. 

 

From the docs:

"The array must have a key=value pair for each custom field in the workspace that is editable, including fields with unchanged values. If you omit an editable field, the field's value is set to null.  "

 

We left out some editable fields that weren't changing and the request was failing.  Thanks for the help

0 Likes