last day (38 days later) » 

4:37 PM
0
A: error while invoking api from api console in store

BeeUsually TypeError: Failed to fetch comes because of the self-signed certificate which comes by default with the server. If that is the case, accepting the security certificate from the browser should fix the problem. From docs[2]: Troubleshooting If you cannot invoke the API's HTTPS end...

 
I tried that by browsing the https api end point. It redirected to the carbon admin console page . I entered my credentials . It again redirected to the page with the address as the https endpoint with https://<api host>/mynewapi/v1.0.0/getdetails?loginStatus=true. It did not ask to accept any certificates . The page displayed the error as Error 405 - Method Not Allowed. But if I invoke the endpoint without ?loginStatus-true fron curl -k , i am able to get the result.
 
Bee
You mean, with that query param, curl also fails?
 
: [-1234] [] [2019-02-04 07:24:42,007] WARN {org.owasp.csrfguard.log.JavaLogger } - potential cross-site request forgery (CSRF) attack thwarted (user:<anonymou s>, ip:<some ip>, method:OPTIONS, uri:/mynewapi/v1.0.0/getdetails, error:re quired token is missing from the request) {org.owasp.csrfguard.log.JavaLogger
I tried curl with ?loginStatus= true . It returns a result. So with or without ?loginStatus=true curl -k returns the expected response
 
Bee
Can be a CORS issue. Please check browser console, while invoking in ui. See if there are any errors printed.
 
Error 405 - Method Not Allowed
 
Bee
4:37 PM
Can you post a screenshot of your API resources and the error message you see while invoking?
 
I tried adding snapshots . Somehow the images are not showing up
 
Bee
You have added it wrong. Just add an image and don't edit text.
 
@peter I do not see any option to add image otherwise without editing text. Meanwhile I have also observed another stuff. The wso2 api manager is installed on a ec2 instance . The load balancer url is mapped to a subdomain url.
@peter When it is invoked from command line on the same server , we get the response even when using the subdomain instead of the hostname [ec2-user@ip-<instance ip> bin]$ curl -k https://<subdomain url>.com:8243/mynewapi/v1.0.0/getdetails { "data" : "MyNewAPI"}
@peter When the api is invoked from any other AWS instance or from another server it gets denied [ec2-user@ip-<instance ip> ~]$ curl -v -k https://<subdomain url>.com:8243/mynewapi/v1.0.0/getdetails About to connect() to <subdomain url>.com port 8243 (#0) Trying <some ip>... Connected to <subdomain url>.com (<some ip>) port 8243 (#0) Initializing NSS with certpath: sql:/etc/pki/nssdb skipping SSL peer certificate verification SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
@peter > GET /mynewapi/v1.0.0/getdetails HTTP/1.1 > User-Agent: curl/7.29.0 > Host: <subdomain url>.com:8243 > Accept: / > < HTTP/1.1 302 Found < Date: Tue, 05 Feb 2019 07:29:14 GMT < Content-Type: text/html;charset=UTF-8 < Content-Length: 0 < Connection: keep-alive < X-Frame-Options: DENY < X-Content-Type-Options: nosniff < X-XSS-Protection: 1; mode=block < Set-Cookie: JSESSIONID=ACCBE788B180BDA3; Path=/; Secure; HttpOnly < Set-Cookie: requestedURI=../../mynewapi/v1.0.0/getdetails; Path=/; Secure; HttpOnly < Location: https://<subdomain url>.com:8243/carbon/admin/login.jsp
@peter < Server: WSO2 Carbon Server < Connection #0 to host <subdomain url>.com left intact
@peter . Also I checked the port 8243 is open
please see if the logs give any help. I could not find where I can attach the images
 
Bee
upload to somewhere and give links. there is always a way.
 
Added the Images
 
Bee
4:37 PM
Added your images to the question correctly. However, what I wanted to see were the resources you defined in the publisher UI. can you add that too?
And by console logs I meant browser's developer console logs. Please upload those 2 images.
 
Added the images
 
Bee
it's a cors issue as suspected. check the OPTIONS call response in the browser network tab.
 
Is there a way we can resolve this
 
Bee
Show me that OPTIONS request and response headers.
 
Please see in the attached image
 
Bee
4:37 PM
I can't see response headers. It seems the OPTIONS request has failed this time. Can you try again?
A few questions for you. 1) Is your store host and gateway host are different? 2) do you have <Access-Control-Allow-Origin>*</Access-Control-Allow-Origin> in api-manger.xml? 3) Have you configured CORS in the API itself?
 
1) Hosts (Gateway and Store) are same, ports are different. Store - 9443. Gateway - 8243 and 8280 2)Yes <Access-Control-Allow-Origin>*</Access-Control-Allow-Origin> in api-manager.xml 3) CORSis configured , Below is the configuration details Enable API based CORS Configuration - Box is Checked Access Control Allow Origins - Box is Checked All Allow Origins Access Control Allow Headers - authorization Access-Control-Allow-Origin Content-Type SOAPAction Access Control Allow Methods - GET PUT POST DELETE PATCH OPTIONS Access Control Allow Credentials - Box is Checked
i triggered few more times. Can't see response headers
 
Bee
What's the response code of the OPTIONS call?
 
curl -v -k -i -X OPTIONS "https://<subdomainurl>.com:8243/mynewapi/v1.0.0/getdetails" * About to connect() to <subdomainurl>.com port 8243 (#0) * Trying ip address... * Connected to <subdomainurl>.com (ip address) port 8243 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * skipping SSL peer certificate verification * SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 * Server certificate: * subject: CN=*.<domainurl>.com * start date: Jan 22 00:00:00 2019 GMT * expire date: Feb 22 12:00:00 2020 GMT * common name: *.<domainurl>.com
* issuer: CN=Amazon,OU=Server CA 1B,O=Amazon,C=US > OPTIONS /mynewapi/v1.0.0/getdetails HTTP/1.1 > User-Agent: curl/7.29.0 > Host: <subdomainurl>.com:8243 > Accept: / > < HTTP/1.1 302 Found HTTP/1.1 302 Found < Date: Mon, 11 Feb 2019 12:53:33 GMT Date: Mon, 11 Feb 2019 12:53:33 GMT < Content-Type: text/html;charset=UTF-8 Content-Type: text/html;charset=UTF-8 < Content-Length: 0 Content-Length: 0 < Connection: keep-alive Connection: keep-alive
< X-Frame-Options: DENY X-Frame-Options: DENY < X-Content-Type-Options: nosniff X-Content-Type-Options: nosniff < X-XSS-Protection: 1; mode=block X-XSS-Protection: 1; mode=block < Set-Cookie: JSESSIONID=6830E78669A2C0F55F5CB554EE; Path=/; Secure; HttpOnly Set-Cookie: JSESSIONID=6830E78669A2C0F55F5CB554EE; Path=/; Secure; HttpOnly < Set-Cookie: requestedURI=../../mynewapi/v1.0.0/getdetails; Path=/; Secure; HttpOnly Set-Cookie: requestedURI=../../mynewapi/v1.0.0/getdetails; Path=/; Secure; HttpOnly < Location: https://<subdomainurl>.com:8243/carbon/admin/login.jsp
Location: https://<subdomainurl>.com:8243/carbon/admin/login.jsp < Server: WSO2 Carbon Server Server: WSO2 Carbon Server
it is 302 . I triggered from curl but seems it is redirecting to the admin/login.jsp page.
 
Bee
Something seems to be wrong with your deployment. What are the changes you have done in the axis2.xml and catalina-server.xml?
 
axis2.xml in transport Sender https <parameter name="HostnameVerifier">AllowAll</parameter> catalina-server.xml Turned compression to off for the two connectors
added the snapshots of request and response headers
Any clues from the details?
 
Bee
4:37 PM
302 is the problem. Does that happen to non-prototype APIs too? And do you have a reverse proxy or LB in front of APIM?
 
I could not try non protoyped apis as there are no backend services present. Yes there is a load balancer in front of APIM.
 
Bee
try with a mock backend. maybe with mocky.io
or you could use the default pizzashack api.
 
I tried invoking an actual rest api . it returns HTTP/1.1 405 Method Not Allowed
but when i replace the endpoint with the actual rest api endpoint I get the response
 
Bee
can u bypass your LB and invoke the server directly? and enabled wire logs and send me logs. lakshanigamage.blogspot.com/2015/03/…
 

  last day (38 days later) »