Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hello,
Can someone try to explain to me what I need to provide to a HTTP request body for context@odata.bind? I am trying to use the API to create a document (and eventually uploading content for a document) and I'm not sure what exactly what context@odata.bind (and SmallThumbnails@odata.bind, PrimaryContent@odata.bind, Thumbnails@odata.bind, Folder@odata.bind, and Attachment@odata.bind) are exactly asking for. I know that it should reference an "entity" or something like that, but I am pretty confused. Additionally, what is @odata.type ? Please help, and thank you! Rest API 2.5 and Windchill 12.1.2.0
Solved! Go to Solution.
Okay, my solution is what I just figured out...and it is very dumb. I am using a curl to send HTTP requests and which in the body I am following the API's documentation body:
{
"Name": "TestDoc1",
"Description": "TestDoc1_Description",
"Title": "TestDoc1_Title",
"Context@odata.bind": "Containers('OR:wt.pdmlink.PDMLinkProduct:48788507')"
}
however, I guess I need an escape when providing the ID for the container. So it should really be:
{
"Name": "TestDoc1",
"Description": "TestDoc1_Description",
"Title": "TestDoc1_Title",
"Context@odata.bind": "Containers('\''OR:wt.pdmlink.PDMLinkProduct:48788507'\'')"
}
Which now will work...I thought my issue was with the actual context and not being allowed to create a document in the context of an organization but that wasn't the case. I should have stuck to using the Windchill REST Services page where the request will be generated for you. Off a whim I had decided to use the WRS curl command generator and noticed the backslashes were being populated for the curl command...but I am happy I figured it out finally.
use something like below :
{
"@odata.type": "#PTC.DocMgmt.MFCDigitalProductModelExchange",
"Description": "xr-16132281_1",
"Name": "xr16132281_Doc_1",
"Context@odata.bind": "PTC.DataAdmin.Containers('OR:wt.pdmlink.PDMLinkProduct:1048703300')",
}
I appreciate the response. Is 'OR:wt.pdmlink.PDMLinkProduct:1048703300' an ID of a container for a product? Or what is it exactly? And for data type is that something I can use for any type of document? Or what is that exactly? Can I use an organization container like 'OR:wt.inf.container.OrgContainer:102609' ? I ask this because I am having some trouble creating products (which are reflected in my other posts).
yep the "OR:wt.pdmlink.PDMLinkProduct:1048703300" is the ID of the prod where the doc is created , it can be also a library :
"OR:Awt.inf.library.WTLibrary:2956965", to be able to cerate product , add your self to an org (I know we are solving this in an other post ) and then add your self under the org product creators table :
for to be able to create dox on org level use something like below :
OR:wt.inf.container.OrgContainer:xxx
So if I am using the OrgContainer, I would still use the PTC.DataAdmin.Containers( in front? and then using the same datatype is okay too?
So when trying with a datatype, it gives me the error odata type: PTC.DocMgmt.MFCDigitalProductModelExchange not allowed here" error and if I take it out it works. But I swear it used to not work and I've tried with the PTC.DataAdmin.Containers... but oh well thanks! Additionally while you're here. I am curious how to get the FolderID? I am running a get request for folders in a container and I am providing a containerID but no folders show up in the response.
Okay, my solution is what I just figured out...and it is very dumb. I am using a curl to send HTTP requests and which in the body I am following the API's documentation body:
{
"Name": "TestDoc1",
"Description": "TestDoc1_Description",
"Title": "TestDoc1_Title",
"Context@odata.bind": "Containers('OR:wt.pdmlink.PDMLinkProduct:48788507')"
}
however, I guess I need an escape when providing the ID for the container. So it should really be:
{
"Name": "TestDoc1",
"Description": "TestDoc1_Description",
"Title": "TestDoc1_Title",
"Context@odata.bind": "Containers('\''OR:wt.pdmlink.PDMLinkProduct:48788507'\'')"
}
Which now will work...I thought my issue was with the actual context and not being allowed to create a document in the context of an organization but that wasn't the case. I should have stuck to using the Windchill REST Services page where the request will be generated for you. Off a whim I had decided to use the WRS curl command generator and noticed the backslashes were being populated for the curl command...but I am happy I figured it out finally.