Api Rest Enabled CORS problem
I have a REST API in webMethods 10.5 I have enabled the CORS option to be able to access from an application in agular, When I make the requests it returns a 200 ok but the body of the response is empty, but if I make the request through the postman if that returns results.
This error occurs in a webMethods installation on windows server, if I run it on a winwos 10 it works correctly.
in case you’re still seeking for a solution, and assuming it’s about a REST API you’ve created in an Integration Server Instance: CORS settings are defined under “Settings” → “Extended”. A minimal configuration looks like this:
The server’s address is it’s hostname, and optionally a port number. The URLs include the scheme, hostname, and optionally a port number, but no /path?query#fragment components. The request headers are specific headers sent from your application to the server’s REST API. A specific example configuration is:
You can identify the relevant parameter values when inspecting an OPTIONS request made by your browser on behalf of the application to the server. Use your browser’s developer tools for inspecting this. The desired host address can be found in the Host header, the application’s URL can be identified in the Origin header, and the request headers are defined in the Access-Control-Request-Headers header.
The result code 200 you’ve mentioned is maybe from such an OPTIONS request, and based on the response from the server your browser decided not the issue the actual API request at all.
More information on CORS configuration can be found in the Integration Server Administrator’s Guide:
Your setup is working in Postman because in that case CORS is irrelevant. There is no application with a separate origin in this case (you could pretend this by setting the Origin header). CORS mechanisms are used by browsers when issuing cross-origin requests, which means that the browser requests a resource from a server located at some address on behalf of an application located at a different address.
I have already solved
The problem was in the client, the Accept header was not being sent correctly and it was not able to receive the Json responses.
I have added the Accept header with the value “application / json” and it works fine.