ADF Dataflow issue with source API query

Daniel Baird 0 Reputation points
2025-02-22T03:15:01.8166667+00:00

am trying to setup an Azure Data Factory Dataflow.

The source is a REST API from Monday.com which uses GraphQL. The API requires POST method, with 3 headers Content-Type "application/json", API-Version "2025-01 " and Authorization: "API token"

The request body requires a query to pull the data. Heres my query example

{ "query":"query { boards(ids: someid) {items_page(limit: 1) {cursor items {id name column_values {column {title} text}}}}}" }

When i run the dataflow it fails with the following

InvalidOperationException: DSL compilation failed: DF-DSL-001 - DSL stream has parsing errors\\nLine 8 Position 11: body: '{ \\nmismatched input

I have tried placing the query into a single line but it is being rejected by the API source with the following error:

at Source 'source2': Failure to read most recent page request: DF-REST_001- Error response from server: Some(<html> <head><title>400 Bad Request</title></head> <body> <center><h1>400 Bad Request</h1></center> <hr><center>cloudflare</center> </body> </html>), Status code: 400. Please check your request url and body. (url:https://api.monday.com/v2/,request body: Some({ "query":"query { boards(ids: some id) {items_page(limit: 1) { cursor items { id name column_values { column { title } text } } } }}" }), request method: POST

The dataflow JSON is automatically created by ADF which shows this and as you can see it is placing , after the first { and last }

    "source(allowSchemaDrift: true,",
                "     validateSchema: false,",
                "     inferDriftedColumnTypes: true,",
                "     format: 'rest',",
                "     timeout: 30,",
                "     headers: ['Content-Type' -> 'application/json', 'API-Version' -> '2025-01', 'Authorization' -> 'Some API Token', 'Accept' -> 'application/json'],",
                "     httpMethod: 'POST',",
                "     body: '{ ",
                "\"query\":\"query { boards(ids: some id) {items_page(limit: 1) { cursor items { id name column_values { column { title } text } } } }}\" ",
                "}',",
                "     paginationRules: ['supportRFC5988' -> 'true'],",
                "     responseFormat: ['type' -> 'json', 'documentForm' -> 'arrayOfDocuments']) ~> source2">```
jsonrestapigraphqlazure-data-factory

I have also changed the source format option from none to JSON and got a Error 415 response advising to check the URL and/or body

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,344 questions
{count} votes

1 answer

Sort by: Most helpful
  1. J N S S Kasyap 860 Reputation points Microsoft External Staff
    2025-02-24T02:49:20.7666667+00:00

    Hi @Daniel Baird

    Thanks for posting your query!

    The 415 error you're facing is due to an issue with the Content-Type or body format of the request sent to the Monday.com GraphQL API. From your description, it looks like there is a formatting issue in the JSON body. The GraphQL query is not being correctly encoded, and this is causing the server to reject the request.

    Headers Section:
    The issues with the code include the use of single quotes (') instead of double quotes (") for JSON keys and values, which is incorrect according to JSON standards. Additionally, the arrow (->) is used incorrectly to separate key-value pairs, whereas JSON requires a colon (:) to properly assign values to keys.

    Correct Code:

    "headers": [
        {"Content-Type": "application/json"},
        {"API-Version": "2025-01"},
        {"Authorization": "Some API Token"},
        {"Accept": "application/json"}
    ], 
    

    The headers are now in the correct JSON format as an array of objects.

    Body Section:
    The issue stems from unnecessary extra quotes and commas in the body, where the query is improperly split, causing incorrect formatting. While escaping quotes inside strings is necessary, the body has excessive escape characters around the query itself, making it hard to read and incorrect. Additionally, the body is not properly wrapped as a valid JSON object, and the structure is fragmented with unnecessary quotes, leading to parsing errors.
    Correct code:

    "body": {
      "query": "query { boards(ids: someid) { items_page(limit: 1) { cursor items { id name column_values { column { title } text } } } } }"
    },
    

    Once the request headers and body are properly formatted, the 415 error should no longer occur.

    I hope this information helps. Please do let us know if you have any further queries.

    Kindly consider upvoting the comment if the information provided is helpful. This can assist other community members in resolving similar issues.

    Thank you.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.