Skip to main content
5-Regular Member
December 13, 2022
Question

500 Error and Empty ContentInfos during stage 2 upload

  • December 13, 2022
  • 1 reply
  • 1441 views
I am using Windchill ProjectLink Release 12.0 and Datecode with CPS 12.0.2.7

File upload of simple text document fails with a 500 internal server error. All calls were made according to this article: https://www.ptc.com/en/support/article/CS330694

I also viewed 2 previous threads on the topic, none of them had solutions posted, even though they were marked solved.
For example: https://community.ptc.com/t5/Windchill/REST-API-Upload-file-Stage2-Failure/m-p/810128?lightbox-message-images-810128=61171i999B9E351FF868A7#M67752

If I modify the boundary, I get empty ContentInfos. Both of these things are wrong.

What is the right way to upload a document?

    1 reply

    17-Peridot
    December 14, 2022

    Hi @DC_10517352,

     

    This is Bhushan from PTC Technical Support.

     

    Can you please check the Windchill REST Services Help Center for example to upload the contents for Documents?

    PTC Document Management Domain Examples: Uploading Content for a Document

     

    Please let me know if you are able to upload content files using given example.

     

    Thanks,

    Bhushan D

    5-Regular Member
    December 15, 2022

    Firstly, the documentation you linked to is in conflict with the article above, which is also in conflict with the Windchill REST Services User Guide. 

    Updating the documentation to give a single consistent protocol format would be a good idea.

     

    That being said, even exactly replicating the format given in the documentation doesn't change the result from an empty ContentInfos.  Side note: This protocol is very unusual.  It doesn't align well with the majority of API clients, and it essentially prohibits certain content in the body of the message, namely, an example on how to perform a file upload in plain text would be prohibited from being uploaded since the boundary appears to be fixed.

     

    Stage 1 upload result:

    {'@odata.context': '$metadata#CacheDescriptor', 'value': [{'FileNames': [190869890], 'FolderId': 5051523725, 'ID': None, 'MasterUrl': 'https://<serverurl>/Windchill/servlet/WindchillGW', 'ReplicaUrl': 'https://<serverurl>/Windchill/servlet/WindchillGW/wt.fv.uploadtocache.DoUploadToCache_Server/doUploadToCache_Master?mk=wt.fv.uploadtocache.DoUploadToCache_Server&VaultId=3849172&FolderId=5051523725&SSC=1&CheckSum=430077438&sT=1671106738&sign=TFE558Yx7QpHb8%2FLwWamEMyOKswnKUA7ZQcHzxPN7Mw%3D&site=https%3A%2F%2F<serverurl>%2FWindchill%2Fservlet%2FWindchillGW&AUTH_CODE=HmacSHA256&isProxy=true&delegate=wt.fv.uploadtocache.DefaultRestFormGeneratorDelegate', 'StreamIds': [239207548], 'VaultId': 3849172}], '@PTC.AppliedContainerContext.LocalTimeZone': 'America/New_York'}

    Header for stage 2:

    {'Authorization': 'Basic <token>', 'CSRF_NONCE': '<nonce>', 'Content-Length': 465, 'Content-Type': 'multipart/form-data; boundary=-----------------------------boundary'}

    URL for stage 2:

    https://<serverurl>/Windchill/servlet/WindchillGW/wt.fv.uploadtocache.DoUploadToCache_Server/doUploadToCache_Master?mk=wt.fv.uploadtocache.DoUploadToCache_Server&VaultId=3849172&FolderId=5051523725&SSC=1&CheckSum=430077438&sT=1671106738&sign=TFE558Yx7QpHb8%2FLwWamEMyOKswnKUA7ZQcHzxPN7Mw%3D&site=https%3A%2F%2F<serverurl>%2FWindchill%2Fservlet%2FWindchillGW&AUTH_CODE=HmacSHA256&isProxy=true&delegate=wt.fv.uploadtocache.DefaultRestFormGeneratorDelegate

    Body for stage 2:

    -----------------------------boundary
    Content-Disposition: form-data; name="Master_URL"
    https://<serverurl>/Windchill/servlet/WindchillGW
    	-----------------------------boundary
    Content-Disposition: form-data; name="CacheDescriptor_array"
    	239207548: 190869890: 239207548
    	-----------------------------boundary
    Content-Disposition: form-data; name="190869890"; filename="<filename>.html"
    test text
    	-----------------------------boundary