POST / PUT Grid row using API

POST / PUT Grid row using API

connor.ferguson
Advocate Advocate
1,124 Views
14 Replies
Message 1 of 15

POST / PUT Grid row using API

connor.ferguson
Advocate
Advocate

I am writing an integration that reads and write from the Fusion Grid using :

Method: "PUT"

BASE_URL + $"workspaces/{workspaceId}/items/{dmsID}/views/13/rows/{rowID}"

 

This regularly gives the below error:

Fusion API Error: {
"errorCode" : "GEN_INVALID_INPUT_SCHEMA",
"message" : "Incorrect payload",
"params" : null,
"url" : null,
"errorClass" : "APIError"
}

 

I have implemented a retry which then seems to work, does anyone know why this is happening?

0 Likes
Accepted solutions (1)
1,125 Views
14 Replies
Replies (14)
Message 2 of 15

sven.dickmans
Autodesk
Autodesk

As the error message indicates an 'incorrect payload', it would be interesting to see an example payload of your requests.

0 Likes
Message 3 of 15

connor.ferguson
Advocate
Advocate

Payload below. Apologies this is a POST not a PUT. Sometimes it works first time. If it errors i wait a second and send the same request again it works. I dont want to have to put the request in a loop to sleep and retry as this will affect performance.

 

 

[{"rowData":[{"__self__":"/api/v3/workspaces/538/views/13/fields/LINE_NUMBER","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.LINE_NUMBER","title":"Integer","type":{"link":"/api/v3/field-types/30","urn":"urn:adsk.plm:tenant.field-type:HTC.30","title":"Integer","deleted":false},"value":1,"isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/DRAWING_POSITION","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.DRAWING_POSITION","title":"Integer","type":{"link":"/api/v3/field-types/30","urn":"urn:adsk.plm:tenant.field-type:HTC.30","title":"Integer","deleted":false},"value":1,"isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/ITEM","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.ITEM","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":"CONNORTEST1","isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/ITEM_NAME","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.ITEM_NAME","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":"JUNCTION BOX","isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/QTY","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.QTY","title":"Float","type":{"link":"/api/v3/field-types/2","urn":"urn:adsk.plm:tenant.field-type:HTC.2","title":"Float","deleted":false},"value":1.0,"isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/TAG_NUMBER","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.TAG_NUMBER","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":"T1","isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/SERIAL_NUMBER","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.SERIAL_NUMBER","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":null,"isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/LIFECYCLE_STATE","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.LIFECYCLE_STATE","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":"Engineering","isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/TRANSPORT_CODE","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.TRANSPORT_CODE","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":"G - Assembled in Shop","isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/NOTE","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.NOTE","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":null,"isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/FLUSHING_PRINCIPLE","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.FLUSHING_PRINCIPLE","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":"Start","isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/CONSUMPTION_TYPE","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.CONSUMPTION_TYPE","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":"Variable","isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/EARLY_RELEASE","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.EARLY_RELEASE","title":"Check Box","type":{"link":"/api/v3/field-types/9","urn":"urn:adsk.plm:tenant.field-type:HTC.9","title":"Check Box","deleted":false},"value":"false","isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/DATE_SENT_TO_D365","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.DATE_SENT_TO_D365","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":"11/8/2024","isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/BOMID","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.BOMID","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":"BOM0000000332","isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/BOMRECID","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.BOMRECID","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":"5638871326","isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/RELATED_FM_BOM_ROW","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.RELATED_FM_BOM_ROW","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":".CONNORTEST1","isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/BOMEXPLORERPARENTID","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.BOMEXPLORERPARENTID","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":"-","isSystemField":false},{"__self__":"/api/v3/workspaces/538/views/13/fields/BOMEXPLORERID","urn":"urn:adsk.plm:tenant.workspace.view.field:HTC.538.13.BOMEXPLORERID","title":"Single Line Text","type":{"link":"/api/v3/field-types/4","urn":"urn:adsk.plm:tenant.field-type:HTC.4","title":"Single Line Text","deleted":false},"value":"3c124458-5cc4-421e-8411-09bb75059342","isSystemField":false}]}]

0 Likes
Message 4 of 15

philipfrench
Collaborator
Collaborator

Another way is to use PATCH to save all the info into a single paragraph field, and then just use an on-edit script to write it into grid rows.

It has the extra advantage of being atomic, and your script could even figure out to update existing or add new rows.

Performance wise, it is a single Rest call, and you won't beat that for speed.

0 Likes
Message 5 of 15

sven.dickmans
Autodesk
Autodesk
Accepted solution

@connor.ferguson Few remarks about the payload: 

a) Why do you pass an Array instead of named properties? I would have expected the payload to start with '{"rowData"', without the square brackets. 

b) You can omit most of the parameters of your payload (type, isSystemField,...). In my solutions, I only pass the link (__self__) and the value (ie as string or object in case of pick list : { value : '/api/v3/workspaces...'})

c) The POST request will always create new grid rows. To update existing grid row entries, you will have to use a PUT request.

d) Does the behavior of your code change if you reduce it? What happens if you pass one Single Line Text field value only? Your payload will set null for a field and another one stores a data value. You may want to remove them from your call to see if the cause any issues.

e) Are there any script errors when you run your API calls?

 

@philipfrench Using scripts might reduce implementation time but it has disadvantages as well: The logic must be implemented in the edit event and therefore will be triggered with every update. It will also add unnecessary (and complex) entries in the Change Log and System Log. And it does not support return values - the API cannot recognize and act on failures when using scripts.

 

0 Likes
Message 6 of 15

connor.ferguson
Advocate
Advocate

Thanks both for the suggestions. Sven as you suggested i removed passing the data in a json array and just passed row data, which still errored but then i added an accept header to my request and it works, seemingly every time!

I put the data in an array because that is how it is formatted by Fusion when creating a grid row.

connorferguson_0-1731334557876.png

But i think my issue is solved now, thanks again.

Message 7 of 15

ThomasRambach
Advisor
Advisor

Is adding or updating a gridview row still even possible using the v3 API? The documentation only shows GET and I haven't had much luck using some of the lessons learned here. 

0 Likes
Message 8 of 15

sven.dickmans
Autodesk
Autodesk

@ThomasRambach Yes it is. This Postman collection may be of help when exploring the V3 API. It includes an example for grid row updates and other use cases. Please see the documentation of the collection's top level page about how to use this collection by creating a fork of the collection and adjusting its variable.

The examples work with new demo/trial tenants directly. If your tenant config and data is different, you will have to adjust the given workspace and dms IDs using the variables.

Message 9 of 15

ThomasRambach
Advisor
Advisor

@sven.dickmans I've used some older Postman collections that you may have created, but this one is absolutely perfect. Thank you. This will help out tremendously.

0 Likes
Message 10 of 15

ThomasRambach
Advisor
Advisor

@sven.dickmans  One more question. Do you have an examples of picking from a picklist when inserting or updating a gridrow?

 

Edit: Nevermind, I got it. Thanks again!

0 Likes
Message 11 of 15

Johnny.Matthys
Participant
Participant

@sven.dickmans I'm not having any luck configuring postman to add an item to a grid row via the v3 REST API.  I utilized the nomenclature found here but I still continue to receive an incorrect payload error.  I have ensured that there is only one field name TEST on the grid tab that is a single line text that can accept up to 50 characters.  There should be no security issues as I have assigned myself every role and every permission possible for this workspace.  I deleted all other fields from that grid tab.  Please see attached screenshots showing the body and headers that I'm using.  I tried copying the data while changing the values directly from that web-page as well as using ChatGPT to create it for me while referencing this page, the postman example, this example, and the fusion manage help site.  Any assistance would be very helpful.  

 

Screenshot 2025-06-02 141257.png

Screenshot 2025-06-02 141135.jpg

0 Likes
Message 12 of 15

philipfrench
Collaborator
Collaborator

When you are stuck like this, try doing the same operation in the browser and tracing what the browser is doing.

Try playing with developer tools, go to the page for your grid, do CTRL + SHIFT + I, go to network tab, then add your grid row.

You can see what the browser is doing for the payload, and note also the Request headers (especially Content-Type).

Now compare that to your Postman example.

 

This is a much more productive approach than chatgtp and following the documentation.

 

Whenever I hit a problem with the rest api, the answer is always found in comparing what I am doing with what the browser is doing.

Message 13 of 15

Johnny.Matthys
Participant
Participant

Thanks for the advice. It was really helpful!  While I am in no way a programmer (hence my reliance on ChatGPT) I was at least able to follow the trail well enough to copy and paste the right thing over to Postman to figure out what the right nomenclature is.  Surprisingly enough ChatGPT would have gotten me there a while back if it didn't keep adding the first '{ "Rows":' call in the body of the post.  Once I figured out where to find the payload in the inspection area it became quite obvious what the error was.  

Message 14 of 15

sven.dickmans
Autodesk
Autodesk

@Johnny.Matthys I am glad that you managed to solve the problem. The advice of @philipfrench is really helpful, it helps exploring the REST API and its capabilities in an easy way.

Is there anything that I could change in my Postmam example that would have helped you resolving the issue quicker?

0 Likes
Message 15 of 15

Johnny.Matthys
Participant
Participant
Unfortunately, I don't believe there is much that would have helped me
figure this out quicker since I lack a reasonable foundation in the subject
matter.
0 Likes