You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I initially hit this issue trying to set up an OpenAPI Connector to some proprietary software. When sending a query to a POST endpoint that only accepts http form data in the application/x-www-form-urlencoded format, it will automatically be sent as multipart/form-data, so the query will fail. If this is supposed to be resolved by populating the headers parameter in the GraphQL query, it's not clear how the that string should be formatted.
I can't share reproduction steps for the original bug since it involves proprietary software, but I found (via the test data) a similar endpoint in the Auckland Museum OpenAPI Specification. They have documentation here and their specification here. We are concerned with the /sparql POST endpoint which produces ["application/sparql-results+json", "application/sparql-results+xml"] and consumes "application/x-www-form-urlencoded". I tried running the sample query in the Auckland Museum documentation . As a curl command it looks like this:
When I run this query, the trace and connector container logs show a SyntaxError: Unexpected token 'P', \"Please use\"... is not valid JSON. The stack is here:
"err":{"type":"InternalServerError","message":"Error encountered when invoking function 'postSparqlPostSparql'","stack":"Error: Error encountered when invoking function 'postSparqlPostSparql'\n at invokeFunction (/functions/node_modules/@hasura/ndc-lambda-sdk/src/execution.ts:184:13)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async executeMutationOperation (/functions/node_modules/@hasura/ndc-lambda-sdk/src/execution.ts:96:18)\n at async executeMutation (/functions/node_modules/@hasura/ndc-lambda-sdk/src/execution.ts:69:18)\n at async Object.mutation (/functions/node_modules/@hasura/ndc-lambda-sdk/src/connector.ts:87:14)\n at async Object.<anonymous> (/functions/node_modules/@hasura/ndc-sdk-typescript/src/server.ts:251:32)","statusCode":500,"details":{"type":"Object","message":"Unexpected token 'P', \"Please use\"... is not valid JSON","stack":"SyntaxError: Unexpected token 'P', \"Please use\"... is not valid JSON\n at JSON.parse (<anonymous>)\n at parseJSONFromBytes (node:internal/deps/undici/undici:5584:19)\n at successSteps (node:internal/deps/undici/undici:5555:27)\n at fullyReadBody (node:internal/deps/undici/undici:1665:9)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async specConsumeBody (node:internal/deps/undici/undici:5564:7)\n at async /functions/api.ts:192:22\n at async postSparqlPostSparql (/functions/functions.ts:182:18)\n at async /functions/node_modules/@hasura/ndc-lambda-sdk/src/execution.ts:176:16\n at async invokeFunction (/functions/node_modules/@hasura/ndc-lambda-sdk/src/execution.ts:172:12)\n"}}
The "Please use" message is suspiciously similar to their error response "Please use either 'application/sparql-results+json' or 'application/sparql-results+xml' as your 'Accept' header". If this is user error, please let me know the appropriate way to set the headers in the GraphQL query. Thank you!
Reproduction Steps
Install DDN and set the current working directory to be wherever you want to build your test supergraph.
Make sure the CLI is up to date (DDN CLI Version: v2.13.0) ddn update-cli
ddn supergraph init .
ddn connector init -i
Pick the hasura/openapi connector. Use default options except for
Description
I initially hit this issue trying to set up an OpenAPI Connector to some proprietary software. When sending a query to a POST endpoint that only accepts http form data in the
application/x-www-form-urlencoded
format, it will automatically be sent asmultipart/form-data
, so the query will fail. If this is supposed to be resolved by populating the headers parameter in the GraphQL query, it's not clear how the that string should be formatted.I can't share reproduction steps for the original bug since it involves proprietary software, but I found (via the test data) a similar endpoint in the Auckland Museum OpenAPI Specification. They have documentation here and their specification here. We are concerned with the /sparql POST endpoint which produces
["application/sparql-results+json", "application/sparql-results+xml"]
and consumes"application/x-www-form-urlencoded"
. I tried running the sample query in the Auckland Museum documentation . As a curl command it looks like this:I tried translating it to a GraphQL query like this:
When I run this query, the trace and connector container logs show a
SyntaxError: Unexpected token 'P', \"Please use\"... is not valid JSON
. The stack is here:The "Please use" message is suspiciously similar to their error response "Please use either 'application/sparql-results+json' or 'application/sparql-results+xml' as your 'Accept' header". If this is user error, please let me know the appropriate way to set the headers in the GraphQL query. Thank you!
Reproduction Steps
ddn update-cli
ddn supergraph init .
ddn connector init -i
hasura/openapi
connector. Use default options except forConnector Name: auckland_openapi
NDC_OAS_DOCUMENT_URI: https://api.aucklandmuseum.com/apidoc
NDC_OAS_BASE_URL: https://api.aucklandmuseum.com
ddn connector introspect auckland_openapi
ddn command add auckland_openapi "*"
ddn supergraph build local
ddn run docker-start
ddn console --local
The text was updated successfully, but these errors were encountered: