Forum Discussion
post request
Hi nicolast29,
I modify the code to split the URL to root and relativepath and add a query to the connection. You can try to use the following query if they suitable for your requirement:
let
vToken = "Bearer " & "TokenXXX",
vSecret = "SecretXXX",
vsociety = "XXXX",
rootURL = "https://api.myunisoft.fr/api",
relativePath = "/v1/export/FEC",
//vUrl = "https://api.myunisoft.fr?export_type=1&from=2021-01-01&to=2021-12-30",
Source =
Json.Document(
Web.Contents(
rootURL,
[
Headers = [
Authorization = vToken,
#"X-Third-Party-Secret" = vSecret,
#"society-id" = vsociety,
#"Content-Type" = "application/json"
],
RelativePath = relativePath,
Query = [
export_type = "1",
from = "2021-01-01",
to = "2021-12-30"
]
]
)
)
in
Source
Regards,
Xiaoxin Sheng
Thanks for your answer
I modify my code with your informations but i still have a reponse error:
DataSource.Error : Web.Contents n'a pas réussi à obtenir le contenu de « https://api.myunisoft.fr/api/v1/export/FEC?export_type=1&from=2021-01-01&to=2021-12-31 » (405) : Method Not Allowed
Détails :
DataSourceKind=Web
DataSourcePath=https://api.myunisoft.fr/api/v1/export/FEC
Url=https://api.myunisoft.fr/api/v1/export/FEC?export_type=1&from=2021-01-01&to=2021-12-31
- nicolast294 years agoHelper V
I make further search,
It seem that i should have a body in order to make a POST request
https://developer.genesys.cloud/forum/t/connecting-with-power-bi/14366
but in my case i should send a empty body
I try by adding this
vbody = "the post method",
Source =
Json.Document(
Web.Contents(
//vURL,
rootURL,
[
Headers = [
Content=Text.ToBinary(vbody),
Authorization = vToken,
#"X-Third-Party-Secret" = vSecret,
#"society-id" = vsociety,
#"Content-Type" = "application/json"
],
RelativePath = relativePath,
Query = [
export_type = "1",
from = "2021-01-01",
to = "2021-12-31"
]
]
)
)
in
Sourcebut i still have a error :
Expression.Error : Désolé... Nous n'avons pas pu convertir une valeur de type Binary en type Text.
Détails :
Value=[Binary]
Type=[Type]It is the same with Content=Text.ToBinary("")
- Anonymous4 years agoNot applicable
Hi nicolast29,
In fact, 'Content' is an optional parameter in web connector and it should list at the same level as 'Header':
let vToken = "Bearer " & "TokenXXX", vSecret = "SecretXXX", vsociety = "XXXX", rootURL = "https://api.myunisoft.fr/api", body = "{}", relativePath = "/v1/export/FEC", //vUrl = "https://api.myunisoft.fr?export_type=1&from=2021-01-01&to=2021-12-30", Source = Json.Document( Web.Contents( rootURL, [ Headers = [ Authorization = vToken, #"X-Third-Party-Secret" = vSecret, #"society-id" = vsociety, #"Content-Type" = "application/json" ], RelativePath = relativePath, Content = Text.ToBinary(body), Query = [ export_type = "1", from = "2021-01-01", to = "2021-12-30" ] ] ) ) in SourceI'm not so sure which type of content your API requirement, maybe you can check the API document and add the corresponding JSON strings in the 'body' step.
Regards,
Xiaoxin Sheng
- nicolast294 years agoHelper V
i still have a problem
I am working on
Thanks