Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Getting CORS error while invoking crowd REST API from my local

Maheswari November 29, 2018

Getting an error

Failed to load resource: the server responded with a status of 401 (Unauthorized)
localhost/:1 Access to XMLHttpRequest at 'http://192.168.50.203:8095/crowd/rest/usermanagement/1/session?validate-password=true&duration=1800' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

while invoking crowd rest api.

No issues when i run it on postman.

How can solve

please help

1 answer

0 votes
Daniel Ponzio
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 30, 2018


Hi Maheswari!

It looks like you're getting a CORS error, so first try going to Crowd and adding 'localhost' under Crowd admin console -> Applications -> Crowd to see if that helps.

Otherwise, there could be some missing headers in your call or an issue with proxy configuration. How is the call different coming from postman vs running it directly? For example, are you running it on the same URL (http://192.168.50.203:8095/crowd), is Crowd running on HTTPS, or do you have a proxy configured?

For example, if you're using CURL you might want to try something like this:

curl -H "Origin: http://192.168.50.203" --verbose \
http://192.168.50.203:8095/crowd/crowd/rest/usermanagement/1/session?validate-password=true&duration=1800

Otherwise, if you're using a proxy or SSL in front of Crowd you should be making the call with the right domain/scheme. If you can add the code you're using to hit the API endpoint as well as your postman call I can see what might be missing. Also, when you run postman, make sure you're running it from the same machine as your code. It could be that postman is adding some headers that are not added when you call it directly.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events