How to resolve 403/500 errors during APIM to APIM communication (hosted in separate virtual networks)

Madala, Hanumantharao 71 Reputation points
2021-07-15T02:12:16.657+00:00

Scenario:
I have two APIM instances deployed in my environment.

  1. hosted in internet segment within first virtual network
  2. hosted in intranet segment within second virtual network
  3. peering is enabled between vnets.

Note: I do not have any issue while testing my api hosted in intranet, which in turn call the backend services (azure app service - webapp)

forward-request (152.089 ms)
{
"response": {
"status": {
"code": 403,
"reason": "Forbidden"
},
"headers": [
{
"name": "Vary",
"value": "Origin"
},
{
"name": "Access-Control-Allow-Origin",
"value": "https://apimanagement.hosting.portal.azure.net"
},
{
"name": "Access-Control-Allow-Credentials",
"value": "true"
},
{
"name": "Access-Control-Expose-Headers",
"value": "Content-Length,Vary"
},
{
"name": "Content-Length",
"value": "45"
},
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Date",
"value": "Thu, 15 Jul 2021 01:52:44 GMT"
}
]
}
}
Outbound
(1.214 ms)↑ Back to top
cors (0.062 ms)
{
"message": "Headers starting with 'Access-Control-' were removed from the response. ",
"headers": [
{
"name": "Vary",
"value": "Origin,Origin"
},
{
"name": "Access-Control-Allow-Credentials",
"value": "true"
},
{
"name": "Access-Control-Expose-Headers",
"value": "Vary,Content-Length,Date,Ocp-Apim-Trace-Location"
}
]
}
transfer-response (1.152 ms)
{
"message": "Response has been sent to the caller in full"
}

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,746 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Madala, Hanumantharao 71 Reputation points
    2021-07-15T23:34:37.83+00:00

    I would need the sample front-end apim api's code to call backend apim api service, which will call target backend service (azure app service)

    How to fix the below error? Appreciate some guidance here. thanks.

    set-body (0.406 ms)
    {
    "messages": [
    {
    "message": "Expression evaluation failed.",
    "expression": "\n var response = context.Response.Body.As<JObject>();\n \n return response.ToString();\n ",
    "details": "Object reference not set to an instance of an object."
    },
    "Expression evaluation failed. Object reference not set to an instance of an object.",
    "Object reference not set to an instance of an object."
    ]
    }