Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Richard_Halsall
Helper III
Helper III

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
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

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}}}}}"])

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

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}}}}}"])

@lbendlin Many thanks

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors