Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
Hello Everyone,
I am trying to extract the BOM of an assembly in windchill through REST APIs. However, since I am unfamiliar with what attributes to pass in the body of this post request, im running into error 400s.
Here's what I have done so far:
I have the following assembly item:
{ "CreatedOn": "2024-06-13T02:09:02+05:00", "ID": "OR:wt.part.WTPart:112282", "LastModified": "2024-06-13T02:09:02+05:00", "AlternateNumber": null, "AssemblyMode": { "Value": "separable", "Display": "Separable" }, "BOMType": null, "CabinetName": "Default", "ChangeStatus": null, "CheckOutStatus": "", "CheckoutState": "Checked in", "Comments": null, "ConfigurableModule": { "Value": "standard", "Display": "No" }, "CreatedBy": "ahsan", "DefaultTraceCode": { "Value": "0", "Display": "Untraced" }, "DefaultUnit": { "Value": "ea", "Display": "each" }, "EndItem": false, "FolderLocation": "/GOLF_CART/Design", "FolderName": "Design", "GatheringPart": false, "GeneralStatus": null, "Identity": "Part - GC000003, LEFT_ACTUATOR, A.1 (Design)", "Latest": true, "LifeCycleTemplateName": "Basic", "ModifiedBy": "ahsan", "Name": "LEFT_ACTUATOR", "Number": "GC000003", "ObjectType": "Part", "PhantomManufacturingPart": false, "Revision": "A", "ShareStatus": null, "Source": { "Value": "make", "Display": "Make" }, "State": { "Value": "INWORK", "Display": "In Work" }, "Supersedes": null, "TranslationName": "LEFT_ACTUATOR", "TypeIcon": { "Path": "http://windchill.gosaas.io/Windchill/wtcore/images/part.gif", "Tooltip": "Part" }, "Version": "A.1 (Design)", "VersionID": "VR:wt.part.WTPart:112281", "View": "Design", "WorkInProgressState": { "Value": "c/i", "Display": "Checked in" } },
Using the ID from above(OR:wt.part.WTPart:112282) I send the following POST request from the API catalogue of Windchill:
curl -X 'POST' \ 'http://windchill.gosaas.io:80/Windchill/servlet/odata/v6/ProdMgmt/Parts('\''OR%3Awt.part.WTPart%3A112282'\'')/PTC.ProdMgmt.GetMultiLevelComponentsReport?%24count=false' \ -H 'accept: application/json' \ -H 'CSRF_NONCE: k7J6XhG7Zm+N2PMVy9AqG3iLKgHU4YB098cMLHT/EgHX6qYk/tMzLELhAguioLJW/fVDLkLcDVK36cQkqotDZymKV1y67skk/ttJDVr1AyfKkpYk1f44B0PSBR3A7ZRM3ttJJkfDMh25ob1B+/dKBCbyWw==' \ -H 'Content-Type: application/json' \ -d '{ "ShowSingleLevelReport": false, "NavigationCriteria": { "ApplyToTopLevelObject": true, "Name": "OR:wt.part.WTPart:112282", "UseDefaultForUnresolved": true, "ApplicationName": "", "SharedToAll": true, "HideUnresolvedDependents": true, "Centricity": true, "ApplicableType": "", "ConfigSpecs": [ { "@odata.type": "#PTC.NavCriteria.WTPartStandardConfigSpec","WorkingIncluded": true,"View": "Manufacturing" } ], "Filters": [ { "@odata.type": "#PTC.NavCriteria.SphereSpatialFilter" } ], "ID": "OR:wt.part.WTPart:112282" } }'
I get various 400 code errors, the latest of which is:
{ "error": { "code": null, "message": "class wt.part.WTPart cannot be cast to class wt.filter.NavigationCriteria (wt.part.WTPart and wt.filter.NavigationCriteria are in unnamed module of loader 'app')" } }
If someone could check and explain the attributes I pass in the body of the post request and point out the problem, I would greatly appreciate it. Thanks in advance.
p.s. apologies for the formatting of this post
Solved! Go to Solution.
I was able to successfully extract the BOM through REST APIs, so I wanted to leave the resource that helped for anyone getting similar errors in the future.
For Windchill 13.0, Please refer to the following documentation: https://www.ptc.com/support/-/media/support/refdocs/Windchill_REST_Services/2,-d-,7/wrs.pdf?sc_lang=en
Look for the GetPartStructure api. Make sure to use the expand operation in the query parameters. Your body should look something like this:
I was able to successfully extract the BOM through REST APIs, so I wanted to leave the resource that helped for anyone getting similar errors in the future.
For Windchill 13.0, Please refer to the following documentation: https://www.ptc.com/support/-/media/support/refdocs/Windchill_REST_Services/2,-d-,7/wrs.pdf?sc_lang=en
Look for the GetPartStructure api. Make sure to use the expand operation in the query parameters. Your body should look something like this:
Hi @saood
I am glad that you figured this out. I trust this will help other users along the way!