|
|
|
Re: Sirus Web Creating elements programmatically [message #1843579 is a reply to message #1843526] |
Mon, 09 August 2021 11:51   |
Andre Seecamp Messages: 13 Registered: July 2021 |
Junior Member |
|
|
Hello,
I struggle with the query for the document upload (I have not used GraphQL before). I try to upload a file through the GraphiQL interface, but I get an error which I cannot resolve. Later I want to perform this query through java code.
The query looks like this right now
mutation uploadDocument($input: UploadDocumentInput!){ uploadDocument(input: $input) {
__typename
... on ErrorPayload {message}}}
Query Variables
{ "input": {
"id": "8016b11c-f8f6-11eb-9a03-0242ac130003",
"file": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><eed:AHPCC xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:eed=\"http://www.example.org/eed\"><application name=\"app1\"/></eed:AHPCC>",
"editingContextId": "f633f3db-65f3-4299-a989-938a47209045"
}
}
But I get the following error:
{
"errors": [
{
"message": "Exception while fetching data (/uploadDocument) : null",
"locations": [
{
"line": 14,
"column": 56
}
],
"path": [
"uploadDocument"
],
"extensions": {
"classification": "DataFetchingException"
}
}
],
"data": null
}
What is not correct in my query?
Also, I have not found a way to extract the current representation with the api as XMI. Is there no function for that? Is there another way I can do that?
[Updated on: Mon, 09 August 2021 12:32] Report message to a moderator
|
|
|
Re: Sirus Web Creating elements programmatically [message #1843659 is a reply to message #1843579] |
Thu, 12 August 2021 13:38   |
Andre Seecamp Messages: 13 Registered: July 2021 |
Junior Member |
|
|
I took a further look into the api and found out that I probably have to use a multipart request. Now I encounter an error which says that I am using the wrong media type.
My request looks like this:
curl localhost:8080/api/graphql \
-X POST \
-F operations='{ "query": "mutation uploadDocument($input: UploadDocumentInput!){ uploadDocument(input: $input) { __typename ... on ErrorPayload {message}}}", "variables": { "input": {"id": "8016b11c-f8f6-11eb-9a03-0242ac130003","editingContextId": "531c38f2-d87c-4a41-b740-7693d11a5c40","file": null } } }'\
-F map='{ "0":["variables.file"] }' \
-F 0=@Model.json
and the error message is the following:
{
"timestamp": 1628773563083,
"status": 415,
"error": "Unsupported Media Type",
"path": "/api/graphql"
}
If anybody knows what causes the error I would be grateful for your help.
[Updated on: Thu, 12 August 2021 13:39] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02518 seconds