Non-file content upload
You can include non-file content in the multi-part form POST request.
The part of a multi-part form that represents an uploaded content element does not need to be a
file. It can be any data that is sent as the content of that part. Normally, when uploading a file,
the tool or library that executes the request adds certain header values for that file part such as
the file name and content type. If the part does not contain these header values, additional fields
contentType and retrievalName need to be specified in the graphql
text to assign those values.
The following curl example specifies the uploaded content as normal text with the
contentType and retrievalName field
values:curl -v https://example.server.ibm.com/content-services-graphql/graphql \
--header 'ECM-CS-XSRF-Token:a251fb4a-88df-4d9d-b38f-5ce80e603e22' \
--header 'Cookie:ECM-CS-XSRF-Token=a251fb4a-88df-4d9d-b38f-5ce80e603e22' \
-u myuser:mypwd \
-F graphql='{
"query": "mutation ($contvar:String) {
createDocument(repositoryIdentifier:\"OS1\"
documentProperties: {
name: \"Test Doc\"
contentElements:{
replace: [
{
type: CONTENT_TRANSFER
contentType: \"text/plain\"
subContentTransfer: {
retrievalName: \"SimpleDocument.txt\"
content:$contvar
}
}
]
}
}
)
{ id name }
}",
"variables":{
"contvar":null
}
}' \
-F contvar='This is a test of specifying content as normal text rather than uploading a file.' If the fields contentType and retrievalName are not specified,
the Content Engine server generates default values like application/octet-stream
for the content type and file0 or file1 for the
retrievalName.