Post not working in UI

sidd-harth
Participant V

Hi guys, I have a simple proxy with a Post resource which has Extract & Assign Policies and an webpage with signup form with ajax call to do post.

Post works in Apigee console and reflects in BaaS. But when I try it with a webpage I get a 200OK in trace with no error in webpage, but it doesn't show up in BaaS.

It is working for other proxies,but now in trace it is showing OPTIONS Method, can anyone explain me why this method is being showed in trace when I did not mention it anywhere in the proxy.

options.jpg

@Maruti Chand

0 6 417
6 REPLIES 6

Not applicable
@Barahalikar Siddharth

I believe you are trying to hit it from one domain and the proxy resides in another domain/apigee domain in your case.

You need use the CORS policy which set following headers

  1. Access-Control-Allow-Origin
  2. Access-Control-Allow-Headers

and couple of more as described in policy url based on the need.

Usually when there is a cross domain issue, browser sends the preflight request with OPTIONS as a method to fetch what all Verbs/Methods are allowed and if any other domain can hit it.

If you set the CORS policy, it will set the necessary headers on proxy side and you will be able to hit it.

Let me know if it solves your problem.

@Gaurav Vishwas Joshi Thank you for answering, yes I'm aware of the CORS policy/cross domain issue, apart from that I have a question..

I was using the same technique before for posting same data through an UI page and it used to work before without any cross domain issue.

Now I'm trying to do the same thing, which gives the cross domain issue.

Why didn't it happen before?

There could be lot of reason for this that it may abruptly stopped working. One of the frequent which I see is the browser,environment etc.. Check if any of the proxy is causing this if you are working from office.

I also happen to see this couple of times. What I usually do is clear the browser cache, change in proxy etc. It help me get over this issue.

Not applicable

Hi @Barahalikar Siddharth ,

Simple requests are requests that meet the following criteria:

  • HTTP Method matches (case-sensitive) one of:
    • HEAD
    • GET
    • POST
  • HTTP Headers matches (case-insensitive):
    • Accept
    • Accept-Language
    • Content-Language
    • Last-Event-ID
    • Content-Type, but only if the value is one of:
      • application/x-www-form-urlencoded
      • multipart/form-data
      • text/plain

Simple requests are characterised as such because they can already be made from a browser without using CORS (check here http://www.w3.org/TR/cors/#resource-preflight-requests for more info ).

Probably earlier you have one of the above 3 content-types ?

BTW did it ever work from browser ?

and BaaS by default support CORS so Baas was doing that for you and you never noticed ?

Yeah maruti even earlier I was using the same steps which I had used for this proxy and yes that worked in Chrome & Mozilla without any cross domain issue.

Anyway in this proxy I added Cors and OptionsPreFlight conditions but still from browser I cannot hit the resource which has extract & assign policies.

Though I'm giving the right path in ajax call the condition is failing.

flow.jpg

@Barahalikar Siddharth Pls attach your bundle and your network calls from the browser so that I can have a look . thanks.