cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Stevel
Advocate IV
Advocate IV

APIM custom connector - no content response

Hi,

I'm building a custom connector between PowerApps and Azure API management. We can call the API endpoint from CURL, Postman and SwaggerHub getting a valid response.

 

When we export the swagger 2.0 json file from APIM and import it into our custom connector it appears OK (after we add the required 200 and 405 responses to the json file). We then proceed to authorize the API in the connection (adding the API key) and test the connection at which time we get  an empty response body.

 

When I run the test in the PowerApps Connector Test tab I see (bold added):

Request:

URL:

https://msmanaged-na.azure-apim.net/apim/zpatient-xxxxxxxxxxxxxxxxxxxxxxxx/24

 

Method: Get

Headers:

{

  "Authorization": "Bearer eyJ0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

}

 

Response

Status

(200)

Headers

{

  "content-length": "0",

  "date": "Fri, 21 Feb 2020 15:25:58 GMT",

  "request-context": "appId=cid-v1:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

}

Body (blank)

 

Schema validation:

Property "" type mismatch, Expected: "object", Actual: "string".

 

Any ideas why we are unable to get a proper response from our APIM call using PowerApps?

 

Thanks!
....Steve

 

In Postman, CURL and swaggerhub I get this response (for example):

{
"resourceType": "Patient",
"id": "24",
"extension": [
{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
"valueCodeableConcept": {
"coding": [
{
"system": "urn:oid:xxxxxxxxxxxxxxxxxxxxxxxxx",
"code": "2106-3",
"display": "White"
},
{
"system": "urn:oid:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"code": "2028-9",
"display": "Asian"
},
{
"system": "urn:oid:xxxxxxxxxxxxxxxxxxxxxxxxx",
"code": "2076-8",
"display": "Native Hawaiian or Other Pacific Islander"
}
]
}
},
{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity",
"valueCodeableConcept": {
"coding": [
{
"system": "urn:oid:xxxxxxxxxxxxxxxxxxxx",
"code": "2186-5",
"display": "Not Hispanic or Latino"
}
]
}
}
],
"name": [
{
"text": "BBBBBBB AAAAAA",
"family": "AAAAAA",
"given": [
"BBBBBBBB"
]
},
{
"use": "old",
"text": "BBBBBB,XXXXXXXX"
}
],
"gender": "male",
"birthDate": "2009-xx-xx",
"deceasedBoolean": false,
"address": [
{
"use": "home",
"line": [
"123 Test Ave"
],
"city": "Test",
"state": "MA",
"postalCode": "02130"
}
],
"photo": [
{
"id": "24",
"url": "PatientImage/24"
}
]
}

 

18 REPLIES 18

Add this to your APIM inbound policy. You can do the same using a policy configuration, form-based editor.

 

        <cors>
            <allowed-origins>
                <origin>https://flow.microsoft.com</origin>
            </allowed-origins>
            <allowed-methods>
                <method>*</method>
            </allowed-methods>
            <allowed-headers>
                <header>*</header>
            </allowed-headers>
            <expose-headers>
                <header>*</header>
            </expose-headers>
        </cors>
Anonymous
Not applicable

Hello,

I found that adding * and limiting what has access works well. Taking the default to allow anyone to come in is fine. The reason is because you are already secure via subscription key or other authorization methodologies and policies. When you go to the method you can add the default CORs policy.

Hi, 

 

Could it be that I have to adjust some settings within powerapps platform?

 

varsha_dhawale
Microsoft
Microsoft

Hi wanted to update the Key used to access the API was not correct which was configured in Azure Function. So passed that key as parameter to API and bingoo... could connect the API and recived the desired response. So we also need to check the Key that is configured to access the API

Anonymous
Not applicable

 This actually didn't work. I am still receiving the errors.

sidhem
Frequent Visitor

Hei @Anonymous , Were you able to resolve this ? We ran into same the same issue in our environment.

 

Any help here is appreciated. 

Thanks!

kbsicdp
New Member

I am getting same issue, even after allowing cors for any domain

Getting same issue, even after setting cors

 

<cors>
            <allowed-origins>
                <origin>*</origin>
            </allowed-origins>
            <allowed-methods>
                <method>GET</method>
                <method>POST</method>
            </allowed-methods>
        </cors>

 

 

Hi there @aroy2020 , Can you be kind enough to provide some more information on this. Where do I go to set the cors policy exactly? thanks in advance

This is the solution to this error. I have also gotten it a couple times where I had an API that was returning a string in the body, instead of an object payload in the body. Please look at the OpenAPI definition that Kris links above.

 

To be clear, instead of 

 

{

   "body": "string"

}

 

The API response should be:

 

{

  "body": { "id: "string" }

}

 

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,040)