Azure API Management> CORS and POST

I use Azure API Management to provide a clean interface to third parties for integration purposes.

I want to do a POST with a JSON object to create this object in the backend. This works fine on the test console available on the portal site, but does not work when I try to make a simple client script from a web page:

$.ajax({ url: 'https://.azure-api.net/api/samplerequest/create?' + $.param(params), type: 'POST', data: JSON.stringify(sampleRequest), contentType: "application/json; charset=utf-8", dataType: "json", success: function (data, par2, par3) { $("#txtResult").val(JSON.stringify(data)); } }); 

Setting the contentType header to "application / json" causes the browser to first make an OPTIONS call. My WebAPI project is configured to enable CORS, and I checked this. My WebAPI project returns the following headers for the OPTIONS method:

Access-Control-Allow-Head ... content-type Access-Control-Allow-Orig ... *

However, if I try to call this operation using the Azure Management API, I get a status of 200 for the OPTIONS method, but there are no other headers. I tried many configuration policies, this was my last attempt:

 <policies> <inbound> <base /> <cors> <allowed-origins> <origin>*</origin> <!-- allow any --> </allowed-origins> <allowed-methods> <method>POST</method> <method>OPTIONS</method> </allowed-methods> <allowed-headers> <header>contentType</header> </allowed-headers> </cors> </inbound> <outbound> <base /> </outbound> </policies> 

What am I missing to make this work?

+8
javascript azure-api-management
source share

No one has answered this question yet.

See similar questions:

one
CORS Preflight request not working with Azure API Management

or similar:

1379
JavaScript submission request, how to submit a form
1273
How to manage redirect request after jQuery Ajax call
6
CosmosDb with DocumentDB API through Azure Management API
3
How are permissions allowed to use the Azure Management API?
3
Azure API Management does not send CORS header to 4xx
one
No certificate when Azure API Manager calls Azure APP service
one
Authorization using the Azure Management API and oAuth2
one
CORS Preflight request not working with Azure API Management
0
Api Management returns an empty response if a header is present

All Articles