I'm trying to send a SOAP request to get XML data from a REST API.
I tested the request on SOAP UI and also with PHP and it is working. The API needs a token and customer key to get a response from the API. When I do it on Power Query I get this error:
DataSource.Error: Web.Contents failed to get contents from 'https://service4.ultipro.com/services/EmployeePerson' (415): Unsupported Media Type
Details:
DataSourceKind=Web
DataSourcePath=https://service4.ultipro.com/services/EmployeePerson
Url=https://service4.ultipro.com/services/EmployeePerson
I think is something with the syntax. This is my code for the request:
let
Source = Xml.Tables(Web.Contents("https://service4.ultipro.com/services/EmployeePerson"
,[Content=Text.ToBinary("<s:Envelope xmlns:a='http://www.w3.org/2005/08/addressing' xmlns:s='http://www.w3.org/2003/05/soap-envelope'><s:Header><a:Action s:mustUnderstand='1'>http://www.ultipro.com/services/employeeperson/IEmployeePerson/FindPeople</a:Action> <UltiProToken xmlns='http://www.ultimatesoftware.com/foundation/authentication/ultiprotoken'>6fsdfdsfsdf54acdsfsdfdsfsdf6</UltiProToken> <ClientAccessKey xmlns='http://www.ultimatesoftware.com/foundation/authentication/clientaccesskey"&Character.FromNumber(34)&">ABCDE</ClientAccessKey> </s:Header><s:Body><FindPeople xmlns='http://www.ultipro.com/services/employeeperson'><query xmlns:b='http://www.ultipro.com/contracts' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'><b:EmployeeNumber /> <b:FirstName> <b:FormerName /> <b:FullOrPartTime /> <b:Job /> <b:LastHire /> <b:LastName /> <b:Location /> <b
riginalHire /> <b
ageNumber /> <b
ageSize /> <b
ayGroup /> <b
upervisorLastName /> <b:TerminationDate /> <b:TimeClockId /> </query></FindPeople></s:Body></s:Envelope>"),Headers=[#"Accept-Encoding"="gzip,deflate", #"Accept"="Basic fsdfdsfdsfdsMjAxNyE=", #"Content-Type"="text/xml;charset=UTF-8"]]
)),
Table1 = Source{1}[Table],
Table0 = Table1{0}[Table],
Table2 = Table0{0}[Table],
Table3 = Table2{0}[Table],
Table4 = Table3{0}[Table],
Table5 = Table4{1}[Table],
Table6 = Table5{0}[Table],
#"Changed Type" = Table.TransformColumnTypes(Table6,{{"CompanyCode", type text}, {"EmployeeNumber", Int64.Type}, {"FirstName", type text}, {"LastName", type text}})
in
#"Changed Type"
I tried switching text/xml to application/xml and got same error.
According to this website: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415
The error is hapenning because the server refuses to accept the request because the payload format is in an unsupported format.
But I already have a header for xml. Maybe I have to code this differently because the request to the service needs to include a token and customer key?
Or https://service4.ultipro.com/services/EmployeePerson is not compatible with power query?
Thank you in advance