Forum Discussion
Put API with Body
- 2 years ago
Hi LarryBroward ,
I'm not used to work with xml files.
Have you triedXml.Document(Web.Contents(url, [Headers=headers, Content = postData ] ) )or
Excel.Workbook(Web.Contents(url, [Headers=headers, Content = postData ] ) )instead?
Hi LarryBroward ,
that sounds interesting. Never tried it.
Which error message did you get and how did your code look like?
- LarryBroward2 years agoHelper I
I did get passed the authentication error. But I wasn’t able to return the excel file I was expecting.
Here’s the code, let me know if you see anything. The error I am getting in the response is Expression.Error: The parameter is expected to be of type Text.Type or Binary.Type. Details: [Table].
The source works and I can see the xml but the data I am looking for is all put in one column and isn’t formatted in a way that I can use it easily.
let
//apiKey = "your_api_key_here", -- Api Doesn't require a key
username = PARAM_API_USERNAME,
password = PARAM_API_USER_PASSWORD,
auth = "Basic " & Binary.ToText(Text.ToBinary(username & ":" & password), BinaryEncoding.Base64),
apiUrl = PARAM_API_BASE_URL,postData = Text.ToBinary(
//Excel is the default and returns without an OutputMime using postman
"<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes""?>
<ns2:invocationContext xmlns:ns2=""http://collectionspace.org/services/common/invocable"">
<mode>nocontext</mode>
<outputMIME>application/xml</outputMIME>
</ns2:invocationContext> "
),url = apiUrl , headers = [ #"Authorization" = auth,#"Content-Type" = "application/xml"],
source = Xml.Tables(Web.Contents(url, [Headers=headers, Content = postData ] ) ),
xmlResponse = Xml.Document(source)
in
xmlResponsePostman- Send and download gives me an excel file.