Forum Discussion
Form data in power query seemingly not being sent to API
- 3 years ago
Anonymous
let
// Define the URL for obtaining the authorization token
authUrl = "YOUR_AUTH_URL",
// Define the form-data parameters as a record
formData = [
key1 = "value1",
key2 = "value2",
// Add more form-data fields as needed
],
// Convert the record to a JSON text
formDataJson = Text.ToBinary(Json.FromValue(formData)),
// Perform the POST request
response = Web.Contents(authUrl, [
Content = formDataJson,
Headers = [#"Content-Type" = "application/x-www-form-urlencoded"] // Adjust content type if needed
]),
// Parse the response as JSON
jsonResponse = Json.Document(response),
// Extract the authorization token from the response
authToken = jsonResponse[auth_token] // Adjust the field name based on the response structure
in
authTokenIn this example, replace "YOUR_AUTH_URL" with the actual URL to obtain the authorization token. Adjust the formData record to include the necessary form-data fields and their corresponding values.
The error you were encountering might be related to the format of the form-data content. By converting the form-data record to JSON text and specifying the correct content type in the headers, you should be able to perform the POST request successfully.
Please note that the exact structure and requirements may vary based on the API you're working with, so make sure to refer to the API documentation provided by the OEM for accurate information regarding authentication and API usage.
Mahesh0016 and Anonymous , would you be so kind as to guide me here:
Im having similiar trouble, eventually I just get a time out
in postman it is working fine
in PowerBI - It just times out:
Anonymous please share your code for better understanding. Thank You!