Forum Discussion
Converting Postman Request into PowerBI
Given the JSON string you defined as your header content, I first converted it to a record in Power Query and then into a binary (JSON) format using the `Json.FromValue` function.
Even though I haven't tested it, this should get you on your way:
let
username = "",
password = "",
accountcode = "",
bodyContent = [
select = {
"mailing_name",
{
"MAX('stats_date')",
"stats_date"
},
"sum('sent')",
"sum('success')",
"sum('failed')",
"sum('opens')",
"sum('unique_opens')",
"sum('unsubscribes')",
"sum('complaints')",
"sum('clicks')",
"sum('unique_clicks')",
"mailing_id",
"list_id",
"from_address",
"email_message_subject",
"schedule_date"
},
from = "mailing",
group = {
"list_id",
"mailing_id"
},
list_ids = "all",
get_extra_conversion_points = true,
filter = {
{
"stats_date",
">=",
"2020-01-01"
},
{
"stats_date",
"<=",
"2020-12-30"
}
}
],
binaryContent = Json.FromValue(bodyContent),
request = Web.Contents(
"api.ongage.net",
[
Headers = [
#"X_USERNAME" = username,
#"X_PASSWORD" = password,
#"X_ACCOUNT_CODE" = accountcode,
#"Content-Type" = "text/plain"
],
RelativePath = "/api/reports/query",
Query = [],
Content = binaryContent
]
)
in
request
- Ryder6 years agoFrequent Visitor
Getting this error now:
DataSource.Error: Web.Contents failed to get contents from 'http://api.ongage.net/' (400): Bad Request
Details:
DataSourceKind=Web
DataSourcePath=http://api.ongage.net/
Url=http://api.ongage.net/I should mention this is a POST request which from what i'm seeing may have an affect on the syntax?
Thanks for the help guys.
- tonmcg6 years agoResolver II
Do you have Fiddler? If so, capture the traffic from both the Postman request and the Power BI request. I don't have enough information, including what parameters you're passing, to be able to diagnose.
If you compare the headers each of the requests, you will be able narrow down the issue.
Here's a blog post from Chris Webb on using Fiddler with Power Query to help get you started.
- Ryder6 years agoFrequent Visitor
Here's a screen capture of the 400 pbi request vs the 200 postman request:
I'm not entirely sure which one of the postman request to focus in on.
Thank you for the assistance!