Hello, I am in need of some direction on creating a Power Query Post Query in Web Form Data. My attempted code is:
I get the error:
DataSource.Error: Web.Contents failed to get contents from 'https://company.webpage.com/api/1.0/users/?auth=[Auth key]' (500): Internal Server Error
Details:
DataSourceKind=Web
DataSourcePath=https://company.webpage.com/api/1.0/users
Url=https://company.webpage.com/api/1.0/users/?auth=[Auth key]
I reached out to web site owner and they informed me that I was sending a JSON object in the body, and they only support web form data. Can someone help me with making this Web form data??
They sent me working code using Python pulled from Postman:
I am trying to maintain a user data base using API functions is the goal of this post.
Thanks
J.Morris
Power Query:
let
url = "[URL='https://company.webpage.com/?auth [Auth key]
body = "{ ""id"": ""5505"", ""firstname"": ""New"", ""lastname"": ""Admin"", ""email"": ""JFMorris@company.com"", ""phone"": ""1234567890"", ""smsemail"": """", ""externalid"": ""12345""}",
Parsed_JSON = Json.Document(body),
BuildQueryString = Uri.BuildQueryString(Parsed_JSON),
Source = Json.Document(Web.Contents(url,[Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(BuildQueryString) ] ))
in
Source
I get the error:
DataSource.Error: Web.Contents failed to get contents from 'https://company.webpage.com/api/1.0/users/?auth=[Auth key]' (500): Internal Server Error
Details:
DataSourceKind=Web
DataSourcePath=https://company.webpage.com/api/1.0/users
Url=https://company.webpage.com/api/1.0/users/?auth=[Auth key]
I reached out to web site owner and they informed me that I was sending a JSON object in the body, and they only support web form data. Can someone help me with making this Web form data??
They sent me working code using Python pulled from Postman:
Code:
import requests
url = "https://company.webpage.com/api/1.0/users/?auth=[Auth key]"
payload={'id': '5505',
'firstname': 'New',
'lastname': 'Admin',
'email': 'JFMorris@company.com',
'phone': '123',
'smsemail': '',
'externalid': '12345'}
files=[
]
headers = {}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
I am trying to maintain a user data base using API functions is the goal of this post.
Thanks
J.Morris