{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • General /
avatar image
0
Question by Nikhil Purohit · Apr 13, 2018 at 07:52 AM · 2.5k Views apigee edgeapi proxyspec

Calling Api using Open Api Specs shows error Fails to Fetch

Here when i hit api using POSTMAN it works fine but as i use open api specs, hits api it show error Failed to fetch.

See screenshot:

Error in Console is:

nikhilpurohit-eval-test.apigee.net/v1/corsconversion Failed to load resource: the server responded with a status of 404 (Resource not found) c3Rvc-ZG9j-76984:1 Failed to load https://nikhilpurohit-eval-test.apigee.net/v1/corsconversion: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://apigee.com' is therefore not allowed access.

The response had HTTP status code 404. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I attached my revision copy as well as ope api specs

corsconversion-rev1-2018-04-13.zip

openspecs.txt

Thanks

Nikhil Purohit

openspecs.txt (1.7 kB)
error.png (165.4 kB)
corsconversion-rev1-2018-04-13.zip (4.0 kB)
Comment
Add comment Show 3
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Nikhil Purohit · Apr 13, 2018 at 07:53 AM 0
Link

@Sai Saran Vaidyanathan @Alex White

avatar image Ilyas shah · Apr 13, 2018 at 09:38 AM 0
Link

Hi Nikhil, this happened to me as well but only with "http", for "https" i am getting the expected response.

avatar image Nikhil Purohit Ilyas shah · Apr 13, 2018 at 09:40 AM 0
Link

But for me both giving same error

Close

3 Answers

  • Sort: 
avatar image
0

Answer by Karthik Prabhu · Apr 13, 2018 at 09:59 AM

Hello @Nikhil Purohit,

This happens to me as well due to CORS headers that is not being sent from Swagger editor. Could you please upload your spec in developer portal or console location from where you could able to make call.

Let me know if this works.

Thanks,

Karthik

Comment
Add comment Show 3 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Nikhil Purohit · Apr 13, 2018 at 10:05 AM 0
Link

Ya i did this but still it showing same. i already attached OpenSpec so you can use it and resolve bug

avatar image Karthik Prabhu Nikhil Purohit · Apr 13, 2018 at 10:08 AM 0
Link

Let me check

avatar image Nikhil Purohit · Apr 13, 2018 at 10:15 AM 0
Link

revision is also attached

avatar image
0

Answer by Kurt Googler Kanaskie · Apr 13, 2018 at 06:39 PM

Yes, you need to enable CORS for your proxies.

I used a Shared Flow for CORSPreFlow and CORSPostFlow, then add those as Flow Hooks on PreProxy and PostProxy. That way I don't have to mess with each of my proxies.

The PreFlow extracts the headers and assigns them to the response via a RaiseFault on OPTIONS.

You will need to adjust your fault rules if you use them, to ignore the Raise Fault (RF-CORS-Pre-Flight), but you could use a Shared Flow for fault rules too.

See attached.

corspreflow-rev1-2018-04-13.zip

corspostflow-rev1-2018-04-13.zip


corspreflow-rev1-2018-04-13.zip (3.4 kB)
corspostflow-rev1-2018-04-13.zip (1.5 kB)
Comment
Add comment · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Sai Saran Vaidyanathan   · Apr 13, 2018 at 07:05 PM

@Nikhil Purohit

I looked at your code, the proxy definition needed some changes, please update your code with the following

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
    <Description/>
    <PreFlow name="PreFlow">
        <Request>
            <Step>
                <Name>JavaScript-1</Name>
                <Condition>request.verb != "OPTIONS"</Condition>
            </Step>
        </Request>
        <Response/>
    </PreFlow>
    <Flows>
        <Flow name="OptionsPreFlight">
            <Request/>
            <Response>
                <Step>
                    <Name>add-cors</Name>
                </Step>
            </Response>
            <Condition>request.verb == "OPTIONS" AND request.header.origin != null AND request.header.Access-Control-Request-Method != null</Condition>
        </Flow>
    </Flows>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <HTTPProxyConnection>
        <BasePath>/v1/corsconversion</BasePath>
        <Properties/>
        <VirtualHost>default</VirtualHost>
        <VirtualHost>secure</VirtualHost>
    </HTTPProxyConnection>
    <RouteRule name="NoRoute">
        <Condition>request.verb == "OPTIONS" AND request.header.origin != null AND request.header.Access-Control-Request-Method != null</Condition>
    </RouteRule>
    <RouteRule name="default">
        <TargetEndpoint>default</TargetEndpoint>
    </RouteRule>
</ProxyEndpoint>

There were issues with the NoRoute RouteRule, you had a tag after the Flow and few others. I was able to make a call from the CORS tester (https://www.test-cors.org) and it worked. However it did not work from the spec editor. I tried the same from editor.swagger.io as well. I was seeing an error. Looks like its an issue with the editor. However the response works as expected

Comment
Add comment Show 1 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sai Saran Vaidyanathan ♦   · Apr 13, 2018 at 07:07 PM 0
Link

anonymous user - would you be able to help with the error we see in the spec editor ?

Follow this Question

Answers Answers and Comments

89 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Not able to access any proxy 1 Answer

issues using SOAP Message validation policy 0 Answers

Sending Payload as "x-www-form-urlencoded" type using Assign message Policy issue 3 Answers

Handle Fault Rule for "messaging.adaptors.http.flow.ApplicationNotFound" 2 Answers

Element parse errors on deployed project 2 Answers

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges