Spec generation in Apigee Edge

Hello Team,

I am working on Apigee Developer Portal.

Firstly created a proxy in edge and published it to Developer Portal along with spec file(generated in specgen.apistudio.io). While testing API in Developer portal am getting error like method not allowed.

Attached screenshot for the error am getting in Developer Portal.

screenshot-40.png

Spec file yaml code:

swagger: '2.0'
info:
description: 'OpenAPI Specification for the Apigee mock target service endpoint.'
version: 1.0.0
title: CreateOrder
host: sravanig231-eval-sravsgkr.apigee.io
schemes:
- http
- https
paths:
/createorder1:
post:
summary: Send request and view request headers and body
produces:
- application/json
operationId: Send request and view request headers and body
description: 'Send a request and view the resulting request headers and body in JSON format.<p>The request payload can be specified using one of the following formats: application/jsonl.</p>'
parameters:
- name: apikey
in: query
description: Enter apikey value.
required: true
type: string
- name: body
in: body
description: 'Request payload in application/json, application/x-www-form-urlencoded, or application/xml format.'
required: true
schema:
$ref: '#/definitions/Order'
responses:
'200':
description: OK
schema:
$ref: '#/definitions/Response'
definitions:
Order:
type: object
properties:
Date:
type : string
CustomerId:
type : string
CustomerName:
type : string
ItemId:
type : string
ItemName:
type : string
Quantity:
type : string
Response:
type: string
properties:
status:
properties:
code:
type: number
message:
type: string

Can anyone suggest where I did wrong in spec file and also send me the sample spec file for POST method.

Thanks in Advance.

0 9 381
9 REPLIES 9

sidd-harth
Participant V

Did you add cors in the proxy?

Please check and provide the errors in Browser Console.

Hi Siddharth,

I have added CORS in API proxy and attached screenshots for errors in portal.

screenshot-42.png

screenshot-43.png

@lakshmi kv ,

Apigee has two different Developer Portals that suit different requirements.

  • In Integrated Developer Portal, APIs has to be CORS enabled to use tryout feature.
  • In Apigee Drupal Developer Portal, CORS is not required since API calls are made from Server Side.

Hope it helps.

-------------------------------

Anil Sagar

5997-screen-shot-2017-11-23-at-75916-pm.png Learn Apigee Concepts in 4 Minutes HandsOn

Thank You @Anil Sagar @ Google

As you mentioned in second point Apigee Drupal Developer Portal is only access for paid versions or it can access for cloud also?


Drupal portal can be used for both on-prem and cloud but is only for paid version only.

sidd-harth
Participant V

Hi @Santosh Kumar,

I have added CORS in API proxy and attached screenshots for errors in portal.

Please mention which doc you have reffered to add CORS in API Proxy.

In the attached images I can still see the CORS error in Browser console. So the added CORS policy is not being used.

Please follow the steps in this doc,

https://docs.apigee.com/api-platform/develop/adding-cors-support-api-proxy

Thanks for Quick response Siddharth.

I followed that link it is having small issues in my policy. Now am able to get the success response.

That's good to know. BTW what are the small issues?

Try to accept the answer if it solved your issues. It may help others.

I have added Assign message policy in API proxy but unable to get the response after followed that link which you have shared I added below code in flow.

Now am able to get the response.

Flow code:

<Flow name="CORS-Options-PreFlight">
<Request/>
<Response>
<Step>
<Name>add-cors</Name>
</Step>
</Response>
<Condition>(request.verb = "OPTIONS")</Condition>
</Flow>

Assign message Policy code:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="add-cors">
<DisplayName>Add CORS</DisplayName>
<FaultRules/>
<Properties/>
<Set>
<Headers>
<Header name="Access-Control-Allow-Origin">{request.header.origin}</Header>
<Header name="Access-Control-Allow-Headers">origin, x-requested-with, accept, content-type</Header>
<Header name="Access-Control-Max-Age">3628800</Header>
<Header name="Access-Control-Allow-Methods">GET, PUT, POST, DELETE</Header>
</Headers>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="response"/>
</AssignMessage>