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

REST API, Upload file, Stage2 'Failure'

Highlighted
Level 6

REST API, Upload file, Stage2 'Failure'

I am using the ODATA REST API to try and upload new file content to a document per REST API Documentation: WCCG_RESTAPI_173713.pdf, Page ~51.

 

I have successfully executed Stage 1

 

 

POST https://server_base_addresshere/Windchill/servlet/odata/DocMgmt/Documents('OR%3Awt.doc.WTDocument%3A553531117')/PTC.DocMgmt.uploadStage1Action HTTP/1.1
Accept: application/xml
Authorization: Basic basicAuthHash
CSRF_NONCE: FFYxrn635KI1zhh0VyJmx0bN1OttoGAbYzweyD35ipN2mVwGfG5r1wSAi89hoC5HUGZFxgj9sZ8P/y1ALW8ImkiO1JsD/CI5Pz90gRfPtvJwgHEMc2IIlzyGhpt08yU=
Content-Type: application/json; charset=utf-8
Host: windchill.plexus.com
Cookie: JSESSIONID=92811C6234652861D37C0EEA3252D1CE.tomcat2
Content-Length: 15
Expect: 100-continue

{"noOfFiles":1}

I get back a successful set of replicaURL, MasterURL, streamIDs and FileNames.

 

 

I then create a stage 2 request following the guidelines in the rest document

 

POST https://replicaurlBaseAddressHere/Windchill/servlet/WindchillGW/wt.fv.uploadtocache.DoUploadToCache_Server/doUploadToChache_Replica?mk=wt.fv.uploadtocache.DoUploadToCache_Server&VaultId=1027696&FolderId=495134041&CheckSum=55879253&sT=1549994693&sign=q8pdvh4fy1dCM7srwl3%2BOwH2W0Wti7AEpgS2xpfdgHZMpHsTze1WPl2OiB%2FG3FyLPqJCU%2BBkjdbxXuX5IiE4Bw%3D%3D&site=https%3A%2F%2Fbasewindchilladdres.com%2FWindchill%2Fservlet%2FWindchillGW&AUTH_CODE=RSA&isProxy=true&delegate=wt.fv.uploadtocache.DefaultRestFormGeneratorDelegate HTTP/1.1
Accept: application/xml
Authorization: Basic basicauthhash
CSRF_NONCE: FFYxrn635KI1zhh0VyJmx0bN1OttoGAbYzweyD35ipN2mVwGfG5r1wSAi89hoC5HUGZFxgj9sZ8P/y1ALW8ImkiO1JsD/CI5Pz90gRfPtvJwgHEMc2IIlzyGhpt08yU=
Content-Type: multipart/form-data; boundary="-----------------------------boundary"
Host: replicaURLServerHostNameHere
Content-Length: 3027
Expect: 100-continue

-------------------------------boundary
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=Master_URL

https://BaseWindchillurl.com/Windchill/servlet/WindchillGW
-------------------------------boundary
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=CacheDescriptor_array

26646757:29232496:26646757
-------------------------------boundary
Content-Type: text/plain
Content-Disposition: form-data; name=26646757; filename=config.da0; filename*=utf-8''config.da0

[CFG]
config last_saved "16:06:16, 08 Feb 2019"
...file contents here ...
[ENDCFG]

-------------------------------boundary--

This then is sent, and it "works" as in there is no error, but it returns an empty contentInfos structure:

HTTP/1.1 200 200
Date: Tue, 12 Feb 2019 18:04:56 GMT
Server: Apache/2.4.25 (Win64) mod_jk/1.2.42 OpenSSL/1.0.2k
X-Ptc-Connected: 1
X-Frame-Options: ALLOW-FROM https://windchillbaseurl.com
X-do-not-compress-this: 1
Vary: Accept-Encoding,User-Agent
access-control-allow-origin: https://windchillbaseurl.com
access-control-allow-credentials: true
expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Length: 19
Content-Type: text/json;charset=UTF-8

{"contentInfos":[]}

Does anyone have any ideas why? (note the listed data has been sanitized to remove company and password data. So far I have tried the following:

  • A variety of different content types for each of the 3 multi part form parts.
  • Fooled with the cache-descriptor lines a bit
  • Have tried with the source document checked in, checked out, with an already existing file, and w/o.

Any help would be greatly appreciated because I feel like I'm super close to getting this working, but so far w/o any kind of error message to point me in the right direction.

Thanks, Josh Patterson

 

4 REPLIES 4

Re: REST API, Upload file, Stage2 'Failure'

So since I wasn't actually getting an error from stage 2, I looked at the encoded info that stage 3 needs, and there doesn't seem to be any new information in it besides the size of the file created on the server side. So "guessing" that it is the same as the client and transfer file size, I generated a stage 3 request.

Interestingly that returned a object must be checked out error. So I implemented object checkout (however even with checkout I still get back and empty result from stage 2), now I get the following XML error response to stage 3:

<?xml version='1.0' encoding='UTF-8'?><error xmlns="http://docs.oasis-open.org/odata/ns/metadata"><code>null</code><message>3</message></error>

a very helpful null coded error "3".

Re: REST API, Upload file, Stage2 'Failure'

Any news on this? I`m also trying to use upload rest api and i`m getting same error.

Re: REST API, Upload file, Stage2 'Failure'

Unfortunately I have not found a solution. It has shifted to my back burner due to other issues beyond my control, though I would love to get an answer here.

 

Josh

Re: REST API, Upload file, Stage2 'Failure'

I managed to get little bit furder with this. It appears that "boundary" must be always two "-" longer so if you put 

boundary to 123456798 you must start your request body with --123456789.

Problem is that now i`m not getting empty "contentInfos" but server is returning error:

 

2019-02-26 16:28:47,104 ERROR [ajp-nio-127.0.0.1-8010-exec-1] wt.fv.uploadtocache -
java.lang.Exception: java.lang.NullPointerException
at wt.fv.uploadtocache.DoUploadToCache_Server.doMultiPartUploadToCache_Server(DoUploadToCache_Server.java:1848)... 
2019-02-26 16:28:47,120 ERROR [ajp-nio-127.0.0.1-8010-exec-1] wt.fv.uploadtocache.DefaultRestFormGeneratorDelegate - Upload content failed with message [java.lang.NullPointerException]