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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. 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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.