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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Post JSON without PowerBI Reformatting it

I need to send this post data to an API endpoint:

{
    "limit": 5,
    "detailed": "true",
    "policy.complianceStandard": "Scope 2021",
    "timeRange": {
        "type": "to_now",
        "value": "EPOCH"
    },
    "filters": [
        {
            "name": "alert.status",
            "operator": "=",
            "value": "open"
        }
    ]
}

 

I tried formatting this as an array as it looked nicer in my code, but M doesn't seem to like my filters object, the only way I seem to be able to get a single element array with an object in it was to give it a key of 0 but then the remote server gave me a 400 bad request, so I went for the manual approach.

 

        alertPayload = "{
            ""limit"": 10,
            ""detailed"": ""true"",
            ""policy.complianceStandard"": ""Scope 2021"",
            ""timeRange"": {
                ""type"": ""to_now"",
                ""value"":""EPOCH""
            },
            ""filters"": [
                {
                    ""name"": ""alert.status"",
                    ""operator"": ""="",
                    ""value"": ""open"" 
                }
            ]
        }",

        
        responseAlert = Web.Contents("https://api.io/v2/alert", [
            Headers = [
                #"Content-Type" = "application/json",
                #"x-redlock-auth" = token
            ],
            Content = Text.FromBinary(alertPayload)
        ]),

 

If I give alertPayload directly to content it complains, but if I surround it with Text.FromBinary or JSON.FromValue then the remote webserver gives me a 400 bad request indicating M has changed something, is there a way to say post this text to the web server and tell M don't change it or that it's pre-formatted?

 

Thanks in advance.

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

You are supposed to use Text.ToBinary, not Text.FromBinary.

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

You are supposed to use Text.ToBinary, not Text.FromBinary.

Anonymous
Not applicable

Many thanks for this, I think I tried so many things over many days I kept this error in, I installed fiddler and got a bit further, the posted JSON appears to be valid.

 

What's happening is becuase I have:

Prisma = [
    Authentication = [ 
        UsernamePassword = [
            UsernameLabel = "API User",
            PasswordLabel = "API Password"
        ]
    ],
    Label = "Data Connector"
];

Power Query is adding a header:

Authorization: Basic XXXX

 

The remote webserver is replying:

message=request has different values in X-Redlock-Auth and Authorization, unclear which to use.

 

It doesn't understand why I'm sending over an API key and setting the Authorization header to basic.

 

Is there a way to remove Authorisation from the header or change my inputs so I can ask the end user for a username / password (this is how I get the login key) but don't set the header?

 

API Doc: https://docs.paloaltonetworks.com/prisma/prisma-cloud/prisma-cloud-admin/get-started-with-prisma-clo... 

Anonymous
Not applicable

Just an update, I got it to work (thanks for the advice), sharing for completeness

 

I needed:

ManualCredentials = true

 

In the request.

        responseAlert = Web.Contents("https://api.io/v2/alert", [
            Headers = [
                #"Content-Type" = "application/json",
                #"x-redlock-auth" = token
            ],
            Content = Text.ToBinary(alertPayload),
            ManualCredentials = true
        ]),

 

 

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.