Developer portal throwing "Unknown error"

Hi All,

I am new to Apigee & developer portal and getting error while testing my API from the developer portal.

When I execute the API in developer portal, it is throws below error, Am i missing any connection setting? please suggest.

"An unknown error occurred while making the request. Please verify your connection and try again. If you continue to experience issues please contact support"

 

Thank you...

8 REPLIES 8

It's likely a CORS error. 

As I mentioned in my reply to your other question, you can search here on the Apigee community for hints on how to address that.

Also here's a recent screencast. https://youtu.be/OHbuqW_1fP0

 

Hi @dchiesa1 ,

I am using APIGEE X and implemented CORS as you suggested in above vedio but still getting error when I am hitting api proxy via developer portal-

Error-

An unknown error occurred while making the request. Please verify your connection and try again. If you continue to experience issues please contact support

 

Please suggest.

@priyashikhar, Is this Devportal is Drupal based devportal or Integrated one?

Using integrated  developer portal.

Hi @dchiesa1 , @kurtkanaskie 

I am using APIGEE X and implemented CORS as you suggested in above video but still getting error when I am hitting api proxy via developer portal. Also, I do not see any response headers on network tab (picture attached)- is this something to do with the issue?

shrenikkumars_0-1659854002053.png

 


 


 

Also, another thing noticed is in the video CORS policy is attached on Proxy endpoint's Preflow Request but when I create an API on UI with CORS option selected it adds it on Target endpoint's Preflow Request. Suggestions on this, where to add?

Error: An unknown error occurred while making the request. Please verify your connection and try again. If you continue to experience issues please contact support

Request your expertise please.

 

is this something to do with [cors]?

Yes. It's hard to be certain from what you are showing, but what you are showing is consistent with a CORS rejection. In the browser console (right hand side of screen that your screenshot shows), in the Network tab, you will see an error if there is a CORS rejection. The rejection comes from the browser. Effectively the browser refuses to send the outgoing request, and the application code (the Javascript running in the browser) receives an error. Because there was no HTTP request, there is no HTTP response, therefore no HTTP Response headers.

cors-error.png

Request your expertise please.

Please show your CORS policy configuration. You can try fiddling with the outbound requests via this tool: https://dinochiesa.github.io/cors-demonstrator/

 

Thanks @dchiesa1 and @kurtkanaskie 
I was able to resolve my CORS issue and was able to get responses on Apigee DevPortal.

Basically, the other day I wasn't getting the OPTIONS call on trace, so I was not able to understand what's happening. And the reason I wasn't getting OPTIONS on trace was actually because my request was exactly same so the browser didn't need a new OPTIONS call and was using the response of previous one.

That's my assumption of how browser works, correct me if I'm wrong 🙂

So today, when I used Dino's tool (https://dinochiesa.github.io/cors-demonstrator/), it was very easy to keep changing my set of headers that yielded OPTIONS call and was able to understand the issue & resolve.

Issue was: I had 405 Method Not Allowed and 404 Not Found handled in my API that caught the OPTIONS call (so it wasn't a success), so just added an empty flow and that resolved the issue.

<Flow name="PreflightCors">
<Request/>
<Response/>
<Condition>(request.verb = "OPTIONS")</Condition>
</Flow>

I humbly appreciate both of your responses, fastest way to learn & fix the issues @dchiesa1 @kurtkanaskie 

Here's an example CORS policy you can try, it's not meant for production as it allows any origin and any headers. Just put it as the first policy in Proxy PreFlow, not sure why the wizard puts it in the Target Endpoint.

This new CORS policy sort of acts like a Raise Fault in that it returns immediately upon an OPTIONS request.

<CORS continueOnError="false" enabled="true" name="CORS">
    <DisplayName>CORS</DisplayName>
    <AllowOrigins>{request.header.origin}</AllowOrigins>
    <AllowMethods>GET, PUT, POST, DELETE</AllowMethods>
    <AllowHeaders>{substring(request.header.Access-Control-Request-Headers.values,1,-1)}</AllowHeaders>
    <ExposeHeaders>*</ExposeHeaders>
    <MaxAge>60</MaxAge>
    <AllowCredentials>true</AllowCredentials>
    <GeneratePreflightResponse>true</GeneratePreflightResponse>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</CORS>