I 'm tring to run my API in swagger editor. But if I pass oauth token in header it gives me an error that 405 method is not allowed.
One more thing is it's working perfect in postman and terminal with oauth token. So maybe, the issue is with swagger.
Without oauth token it's working perfect in swagger editor.
Without Passing oauth token in header my response is
Request URL:http://172.168.1.28/crowdfunding_api/public/v1.0.1/categories
Request Method:GET
Status Code:200 OK
Remote Address:172.168.1.28:80
Referrer Policy:no-referrer-when-downgrade
and curl url is when response is 200:
curl -X GET "http://172.168.1.28/crowdfunding_api/public/v1.0.1/categories" -H "accept: application/json"
With oauth token in header my response is
Request URL:http://172.168.1.28/crowdfunding_api/public/v1.0.1/categories
Request Method:OPTIONS
Status Code:405 Method Not Allowed
Remote Address:172.168.1.28:80
Referrer Policy:no-referrer-when-downgrade
and curl url is when response is 405:
curl -X GET "http://172.168.1.28/crowdfunding_api/public/v1.0.1/categories" -H "accept: application/json" -H "authorization: 587ded3104e6ba7535642e6fcc217e7aa0f5f087"
Try to add support for OPTIONS method in your REST endpoint wrapper.
Just use something like:
if (method == 'OPTIONS') return;
I had similar 405 error and this helped me (seems that CORS sends OPTIONS first to check headers, whether request is allowed).
Also make sure, that your server returns headers:
Access-Control-Allow-Credentials: "true"
Access-Control-Allow-Origin: "*"
Access-Control-Allow-Headers: "origin, x-requested-with, content-type, authorization"
Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With