Power Query Post Web Form Data

Tiger9136

New Member
Joined
Jul 10, 2017
Messages
19
Hello, I am in need of some direction on creating a Power Query Post Query in Web Form Data. My attempted code is:

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
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,214,929
Messages
6,122,315
Members
449,081
Latest member
tanurai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top