REST API workspace Items

REST API workspace Items

Anonymous
Not applicable
1,781 Views
12 Replies
Message 1 of 13

REST API workspace Items

Anonymous
Not applicable

Hi, 

Is there any way  to extract all dmsid  for the workspace Items ?

I was trying to use https://mytenant.autodeskplm360.net/api/rest/v1/workspaces/{workspace_id}/items to get dbms id to 

parse items individually using  https://mytenant.autodeskplm360.net/api/rest/v1/workspaces/{workspace_id}/items/{dbms_id}. However, I am getting only 10 dbms ids using  https://mytenant.autodeskplm360.net/api/rest/v1/workspaces/{workspace_id}/items 

is there any rest api's URL to fetch all dmsids with workspace id ?

 

Thanks in advance,

Prudhvi

 

0 Likes
1,782 Views
12 Replies
Replies (12)
Message 2 of 13

john.denner
Advocate
Advocate

API v3 and v2 will return more but contain much less detail which is probably what you want if you're going to step through the response JSON and make individual calls after that. 🙂

 

API v3 (slightly slower but smaller response file)

 

GET /api/v3/workspaces/{wsId}/items?limit=1000000

 

API v2 (max limit 5,000. slightly faster but ~50% bigger response file)

 

 

GET /api/v2/workspaces/{wsId}/items?page-size=5000

 

 

 

 

0 Likes
Message 3 of 13

Anonymous
Not applicable

Hi, 

Thank you for the prompt reply to my query. 

While using API V2 I am getting JSON response with some dmsid items using "items?page-size=5000" However, I still have more items in the workspace and I understand that page size should be between 1 and 5000.

While using API V3 I am not getting any items using api/v3/workspaces/{Workspace_ID}/items?limit=1000000. 

instead of that I am getting the below response for https://mytenant.autodeskplm360.net/api/v3/workspaces/{workspaceid}/items?limit=1000000

 

{
  "__self__" : "/api/v3/workspaces/{id}/items?offset=0&limit=1000000",
  "offset" : 0,
  "limit" : 1000000,
  "totalCount" : 0,
  "first" : {
    "link" : "/api/v3/workspaces/{id}/items?offset=0&limit=1000000",
    "title" : "First",
    "deleted" : false,
    "count" : 1000000
  },
  "items" : [ ]
}

is that response is correct ? if not, Do i need to change URL ? 

also I am using PL/SQL as REST API to parse XML so, is there any rest URL that fetch all dmsids with workspace id in XML format ?

0 Likes
Message 4 of 13

john.denner
Advocate
Advocate

Might be a silly question but you are passing a real workspace ID yeah? So the request was successful but the response is empty so possibly the account making the request doesn't have access or you accidentally used the wrong workspace ID? I did this recently and felt really dumb afterwards. Smiley Embarassed But that maybe doesn't explain why v1 and v2 return results if everything is correct.

 

I just tested this again with Postman and it worked, which I know isn't very helpful to you but I wanted to make sure the syntax was good. Are you familiar with Postman? https://www.getpostman.com/apps It is a great program to try these things out. I do A LOT of trial and error and Postman makes it easy to try things out to get your requests formatted correctly.

 

As for the XML part I think most all the endpoints return JSON. There are some that return XML and others that return JSON or XML. So my first attempt would be to change the header property for "Accept" to application/xml and another trick is to append the file type of what you want. This one is very specific to some endpoints and I can't remember which ones do it. I think the search and report endpoints can use that. I wish I could be more helpful in that area. But I'm sure a Autodesk employee can step in and provide more info.

0 Likes
Message 5 of 13

gasevsm
Alumni
Alumni
Greetings,

1. The /v1/ api supports both xml and json formats.
2. The /v2/ is an unsupported api and is on disablement path.
3. The /v3/ api powers the modern ui supporting json-only format; it is pending documentation release.

Having said the above, to define format for request payloads, add to api header:
Content-Type = application/json | application/xml

To define format of response payloads, add to header:
Accept = application/json | application/xml

You can mix eg. send json yet receive xml, to update some non-api reachable areas/fields in FLC via scripting parsing that json format easily, or vice versa, again evaluate your need. I found it to be a good practice to always specify payload type for both request and response, even for endpoints with no outlined payloads just to to be resilient for future in case it does start returning something, i would know the type and how to process it after capture it. Not expected, but still.. get into habit to use these two headers ))

HTH,
Martin


Martin Gasevski | Fusion 360 Team Product Manager
0 Likes
Message 6 of 13

Anonymous
Not applicable

Hi, 

Thank you so much for the reply. 

I can able to send the request in json and receive xml response.  

However, I am trying use  using V1 to fetch dmsids with item id  in the workspace 

https://mytenant.autodeskplm360.net/api/rest/v1/workspaces/{worspace id}/items?page=2&size=1

 Now, in that response how should I identify start dmsid and end dmsid ?

also I am getting only 10 dmsid and I have more how will I get remaining dmsid's in that workspace? 

 

 

0 Likes
Message 7 of 13

nguyentru
Alumni
Alumni

Hi,

 

https://previewhummingbirdinnovations.autodeskplm360.net/api/rest/v1/workspaces/2/items

 

This is all you have to type in order to get all the items in the workspaces.  

 

I hope this helps you get closer to your answer.

 

Thank you,

 

Trung Nguyen

Trung Nguyen | PLM Product Management | Autodesk, Inc.
0 Likes
Message 8 of 13

john.denner
Advocate
Advocate
Sorry but it's not. 😞 It only returns 10 records. That's the whole issue from the original post. I can replicate this with every API call using the items endpoint.
0 Likes
Message 9 of 13

nguyentru
Alumni
Alumni

For v1 Rest API it will all the items within that particular workspace

 

https://previewhummingbirdinnovations.autodeskplm360.net/api/rest/v1/workspaces/2/items

Trung Nguyen | PLM Product Management | Autodesk, Inc.
0 Likes
Message 10 of 13

tony.mandatori
Autodesk
Autodesk

The full URL is:

https://adskmandatt.autodeskplm360.net/api/rest/v1/workspaces/57/items?page=1&size=1000&filterDelete...

 

I see this in the XML WADL for v1.  So adding size = 1000 should help (but it takes a while to come back).

 

It looks like the items are sorted by dmsid.  So you would need to choose a chunk size that works and then iterate until the number of records returned is less than the chunk size.

 

Does this help?

 

0 Likes
Message 11 of 13

john.denner
Advocate
Advocate

Could you please provide a screenshot or something that shows the list.items array returned from the request has more than 10 elements?

2018-05-29_9-52-14.jpg

0 Likes
Message 12 of 13

nguyentru
Alumni
Alumni

Hi John,

 

I stand corrected.  Toni's has the correct statement.

 

https://previewhummingbirdinnovations.autodeskplm360.net/api/rest/v1/workspaces/2/items?page1&size=1...

 

I verified both in postman and URL.

 

 

Trung Nguyen | PLM Product Management | Autodesk, Inc.
0 Likes
Message 13 of 13

tony.mandatori
Autodesk
Autodesk

Here is what I see

 

2018-05-29 13_26_35-Postman.pngNote that I have the entire V1 collection in Postman ... because I imported the WADL.

 

It told me the correct syntax to avoid the guess work.

 

Does this help?

0 Likes