Forum Discussion

Richard_Halsall's avatar
2 years ago
Solved

Converting Postman Body Request to JSON body

Hi

 

I am facing an issue to replicate the body POST request from Postman into PQ.

 

This works in Postman

{
    "query""query { boards (ids: 123456789) { items_page (limit:500, query_params: {rules: [{column_id: \"person\", compare_value: [\"Alex\"], operator: contains_text}]}) { cursor items { id name column_values { column{title} text}}}}}"
}
 
And here is my PQ

let
Key = MondayKey,
Board = id_board,
ColumnID = ColumnIDPerson,
PM = PMAlex,
 
Source = Web.Contents(MondayBaseURL,
 
[
        RelativePath="v2",
        Headers=[
            #"Method"="POST",
            #"Content-Type"="application/json",
            #"Authorization"= Key,
            #"API-Version" = "2023-10"
            ],
            Content=Text.ToBinary("{""query"": { boards (ids: " & Board & ") {items_page (limit:500, query_params: {rules: [{""column_id"": " & ColumnID & " , ""compare_value"":  " & PM & " , ""operator"": contains_text}]}) { cursor items { id name column_values { column{title} text}}}}}""}")
        ]
    ),
    #"JSON" = Json.Document(Source,65001),
 
Highlighted in red is the problem code. I have 2 parameters both text named
ColumnID value = \"person\"
PM value = \"Alex\"
 
Tried multiple formats but just cannot resolve. Any help would be appreciated
 
Thanks
  • Have a look at example 2 Web.Contents - PowerQuery M | Microsoft Learn

     

    Something like

     

    Content = Json.FromValue([query= "query { boards (ids: 123456789) { items_page (limit:500, query_params: {rules: [{column_id: ""person"", compare_value: [""Alex""], operator: contains_text}]}) { cursor items { id name column_values { column{title} text}}}}}"])

2 Replies