cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Unable to execute the get BOM REST API

saood
3-Visitor

Unable to execute the get BOM REST API

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

1 ACCEPTED SOLUTION

Accepted Solutions
saood
3-Visitor
(To:saood)

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:

saood_0-1721038402755.png

View solution in original post

2 REPLIES 2
saood
3-Visitor
(To:saood)

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:

saood_0-1721038402755.png

olivierlp
Community Manager
(To:saood)

Hi @saood 

I am glad that you figured this out. I trust this will help other users along the way!

 

Olivier
Top Tags