Upload basics
Several document mutations allow content to be uploaded, along with other changes to the
document.
Content upload using GraphQL involves a POST with the multi-part form content type. The main GraphQL request text is one part of that multi-part content. The content for content elements being uploaded are in one or more additional parts -- one part for each content element.
In the GraphQL request text, values that correspond to the content being input for a content
element are represented as variables. The variables map by name to the parts in the multi-part form.
For example, the following mutation contains GraphQL request text with variable values in
JSON:
mutation ($contvar:String) {
createDocument(
repositoryIdentifi er:"FNOS1"
documentProperties: {
name: "Test Doc"
contentElements:{
replace: [
{
type: CONTENT_TRANSFER
subContentTransfer: {
content:$contvar
}
. . .
{
"contvar": null
}
For variables representing the parts for the content being uploaded, the values need not
be specified. The name of the variable itself maps to the part. Typically, null is passed as the
value of these variables. You can refer to the following curl
command:curl 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 text such as above example>","variables":{"contvar":null} }' \
-F contvar=@SimpleDocument.txt Two parts are transmitted in the multi-part form. The
first part is the graphql request text itself along with the values of the defined variables. The
second part is the content being uploaded for a content element.