Forum Discussion
Template Apps with Parameters in Anonymous API
- 2 years ago
Hi, JackSelman
According to the error message provided in your image, your credentials are invalid and you need to make sure you have provided the correct credentials for your API. You need to make sure that you have provided the correct credentials for your API and used the correct M code for the request. Here's an example of how to properly set up the Web.Contents function:
let API_URL = "https://my-api.edison365.com/v1/api/", Tenant = "your-tenant", Instance = "your-instance", API_Key = "your-api-key", RelativePath = "odata/RecordReports?$filter=isDeleted eq false", Source = Json.Document(Web.Contents( API_URL, [ Headers = [ #"tenant" = Tenant, #"instance" = Instance, #"Ocp-Apim-Subscription-Key" = API_Key ], RelativePath = RelativePath ] )) in SourceHere's a complete example with dynamic parameters:
let API_URL = "https://my-api.edison365.com/v1/api/", Tenant = Text.From(Parameter_Tenant), Instance = Text.From(Parameter_Instance), API_Key = Text.From(Parameter_API_Key), RelativePath = "odata/RecordReports?$filter=isDeleted eq false", Source = Json.Document(Web.Contents( API_URL, [ Headers = [ #"tenant" = Tenant, #"instance" = Instance, #"Ocp-Apim-Subscription-Key" = API_Key ], RelativePath = RelativePath ] )) in SourceUse tools like Postman to ensure that your API calls are correctly formatted and the API is responding as expected. If anonymous access continues to fail, consider using a service principal or OAuth for authentication, which might require some changes in how you manage tokens.
Best Regards,
hackcrr
If this post helps, then please consider Accept it as the solution and kudos to this post to help the other members find it more quickly
Hi, JackSelman
According to the error message provided in your image, your credentials are invalid and you need to make sure you have provided the correct credentials for your API. You need to make sure that you have provided the correct credentials for your API and used the correct M code for the request. Here's an example of how to properly set up the Web.Contents function:
let
API_URL = "https://my-api.edison365.com/v1/api/",
Tenant = "your-tenant",
Instance = "your-instance",
API_Key = "your-api-key",
RelativePath = "odata/RecordReports?$filter=isDeleted eq false",
Source = Json.Document(Web.Contents(
API_URL,
[
Headers = [
#"tenant" = Tenant,
#"instance" = Instance,
#"Ocp-Apim-Subscription-Key" = API_Key
],
RelativePath = RelativePath
]
))
in
SourceHere's a complete example with dynamic parameters:
let
API_URL = "https://my-api.edison365.com/v1/api/",
Tenant = Text.From(Parameter_Tenant),
Instance = Text.From(Parameter_Instance),
API_Key = Text.From(Parameter_API_Key),
RelativePath = "odata/RecordReports?$filter=isDeleted eq false",
Source = Json.Document(Web.Contents(
API_URL,
[
Headers = [
#"tenant" = Tenant,
#"instance" = Instance,
#"Ocp-Apim-Subscription-Key" = API_Key
],
RelativePath = RelativePath
]
))
in
SourceUse tools like Postman to ensure that your API calls are correctly formatted and the API is responding as expected. If anonymous access continues to fail, consider using a service principal or OAuth for authentication, which might require some changes in how you manage tokens.
Best Regards,
hackcrr
If this post helps, then please consider Accept it as the solution and kudos to this post to help the other members find it more quickly