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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

REST API Uto pdate primary content missing

FransB
4-Participant

REST API Uto pdate primary content missing

Based on the current REST API I was able to upload primary content following some examples using the uploadstage1action and uploadstage3action. However, my use case is to provide an integration that allows to update the primary content. Clearly this can be done easily via the web UI.

There is no obvious method using the REST API. Using the example on a document which already has primary content the uploadstage3action fails with indication that a document cannot have more than 1 primary content.

There are no methods to delete the current primary content, nor to update (PUT/PATCH methods).

This seems like a very normal use case for an integration, and I'm wondering what I'm missing here.

I'm testing with windchill 12, WRS Document Management Domain, API Version 5

 

 

ACCEPTED SOLUTION

Accepted Solutions
ANNA_02
14-Alexandrite
(To:WL_10778105)

@WL_10778105  @FransB I have tried out a custom REST API implementation to update the primary content. You can change the code according to your needs. 

 

 

View solution in original post

8 REPLIES 8

Hi FB_8069857,

 

Thank you for your question. 
I’d like to recommend to bring more details and context to your initial inquiry. Product name, version details etc.

It also helps to have screenshot(s) to better understand what you are trying to do in your process. 

This will increase your chances to receive meaningful help from other Community members. 

Regards,

Vivek N
Community Moderation Team.

FransB
4-Participant
(To:vnamboodheri)

Hi N Vivek,

 

I'm building an external tool that communicates with Windchill 12 using the ODATA REST API.

This REST API and specifically PTC Document Management Domain API Version 5 provides endpoints for all sorts of actions on documents, including setting and retrieving primary content.

There are several examples on how the upload content (primary/attachments), which I have followed and am able to upload primary content for a document that has not yet primary content. However when the WTDocument already has primary content this method of upload fails, with a message that primary content already exists.

There is no endpoint identified in the documentation that describes how to remove existing primary content, or otherwise prepare for a new upload. Clearly updating primary content via the Windchill web interface is no problem and very easy to do.

 

The working example for uploading new primary content can be found here:

Upload file in a WindChill document - OData REST A... - PTC Community

 

The REST interface with its documentation (if enabled) can be found via;

FransB_1-1692872207701.png

 

FransB_0-1692872154188.png

 

HelesicPetr
22-Sapphire I
(To:FransB)

Hi @FransB 

I know it is not solution, you will need to study how to customize WRS

 

You can create own WRS api with own function and write a code that do what you need. Just update the primary content. 

 

You need to customize rest api domain add a endpoint and JSHooks where you write java class code that update the primary content as you need. 

 

This is just idea how it could work

 

here is knowledge hub how to customize WRS

CS183488 - Windchill PLM REST Services - Customization

 

and here is example how the end point with JSHooks is used 

CS389663 - Example of Custom Logic and JSHooks in Windchill Rest Services

 

hope this can help. 

 

PetrH

Any luck in solving this? I am running into the same issue on Windchill v12.1.2.4. I am just a user, not an admin of our Windchill instance. I need to be able to update primary document content programmatically via the REST API. Currently this is failing with the message `{"error":{"code":null,"message":"Can not add more than one primary content to the object."}}` when hitting the endpoint `Windchill/servlet/odata/DocMgmt/Documents('<OID>')/PTC.DocMgmt.UploadStage3Action`.

ANNA_02
14-Alexandrite
(To:WL_10778105)

@WL_10778105  @FransB I have tried out a custom REST API implementation to update the primary content. You can change the code according to your needs. 

 

 

FransB
4-Participant
(To:ANNA_02)

Thanks for spending this effort and showing how it can be done. I'm currently not in a position to update the REST API. I will try my best to get this kind of access and then try your solution.

HelesicPetr
22-Sapphire I
(To:FransB)

Hi all,

I would just add that this is nice and clear example, how to extend the REST API by custom methods where you can do what ever you want

PetrH

It does not appear in the Windchill REST API Documentation page, but you can delete primary content using this endpoint. Then you can attach the new primary content. 

DELETE /Windchill/servlet/odata/v5/DocMgmt/Documents('OR:wt.doc.WTDocument:XXXX')/PrimaryContent

See Article - CS290268 - Is it possible to use Windchill REST Services to replace Primary Content for a WTDocument in Windchill Solutions?

Announcements


Top Tags