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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Using REST API to get a list of all WTParts

PhilK
6-Contributor

Using REST API to get a list of all WTParts

Is there a way to use the rest api to get a list of all wtparts and their attributes?

6 REPLIES 6
rhart
16-Pearl
(To:PhilK)

Hi @PhilK 

 

You can get parts and their attributes but there does seem to be a limit for how many parts in a single query.

 

I can get 140,000 parts with query for a part Numbers containing 'M', but if I make the criteria and broader I get an error, so suspecting the limit is 200,000.

 

https://<mywindchillhost>/Windchill/servlet/odata/v5/ProdMgmt/Parts?$filter=contains(Number%2C'M')&$count=false

 

ldutoit
10-Marble
(To:rhart)

Hi,

 

Yes this is a silly problem that we're also struggling with.

 

So ther requirement is to give Windchill a list of part number and then it needs to bring properties back of all the WTparts that was listed


Tried it via a saved Search Query endpoints supplying part number via KeyWord parameter but for some reasons it omits some parts in the response so doing it via SavedSearch End Point does not work correct. If I run the exact save query in Windchill Front end I get correct list:

 

https://<Wchillhost>/Windchill/servlet/odata/v4/SavedSearch/SavedQueries('OR%3Awt.query.SavedQuery%3A1294983587')/PTC.SavedSearch.ExecuteSavedSearch(Keyword='BN064295%3BBN064517_01%3BBN067254%3BBN067255%3BBN067521%3BBN067521-01%3BBN067521-02%3BBN067521-04%3BBN067521-04001%3BBN067794%3BBN067796%3BBN067797%3BBN067797-01%3BBN067797-02%3BBN067797-03%3BBN067797-04%3BBN067799%3BBN067799-01%3BBN067831%3BBN067833%3BBN067837%3BBN067840%3BBN067842%3BBN067848')


Is it possible to get WTParts out of Windchill with Rest API specifiying the list of WT parts?

rleir
17-Peridot
(To:ldutoit)

You can use a QB parameter and pass in a part number, then QB can report the attributes that you need. Use a python script to call this QB report repeatedly, once per part. 

The python script is not difficult, but I don't have time at the moment to give the details.

ldutoit
10-Marble
(To:rleir)



 

rleir
17-Peridot
(To:ldutoit)

Something like this to run a QB report:

 

 

 

        # returns TSV or XML or XSL text

        static_p = ('servlet/WindchillAuthGW/wt.enterprise.URLProcessor/'
                    'URLTemplateAction?'
                    'Item+Name=Foo-T%2A&'
                    'format=formatCustom&'
                    'xsl2=&'
                    'SET_QUERY_LIMIT=20000&')

        if format == 'XML':
            format_xsl = 'identity.xsl'
        elif format == 'TSV':
            format_xsl = 'tsvFormat.xsl'
 
        sURL = self.wc_url + static_p
        sURL += ('xsl1=templates/reports/'
                 + format_xsl + '&'
                 + 'oid=OR%3Awt.query.template.ReportTemplate%3A'
                 + str(report_ID) + '&'
                 + parm_txt
                 + 'action=ExecuteReport')

        return self.send_to_Windchill(sURL, expect_JSON=False)

 

parm_txt = 'PartNumber=' + p_number + '&'

 

I find the TSV format more useful. cheers -- R  

ldutoit
10-Marble
(To:rleir)

Thank you very much!! I will try it

Announcements


Top Tags