POST to GET using Assign Message Policy

Hello,

I have a bunch of backend APIs built in .NET that uses GET to pass user information such as user ID. These APIs are published on Apigee which is being leveraged by customer Apps. I want to change this design to use POST for newer apps. I don't intent to change the backend APIs but would like to change the design on Apigee proxy. I would like the NEW customer app to consume Apigee POST APIs to send user information and I use the Assign Message policy to convert my POST to GET to be sent to the backend. Is this doable using Assign message policy or I need to write some customer JS?

Thanks

Nitin

Solved Solved
1 5 1,855
1 ACCEPTED SOLUTION

Hi @nitin.kotian

Use the <Verb> tag in Assign Message Poilcy to set <Set> the HTTP Verb in an Assign Message Policy.

<AssignMessage name="AssignMessage-3">
  <AssignTo createNew="true" type="request">request1</AssignTo>
  <Set>
    <Verb>GET</Verb>
  </Set>
  <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
</AssignMessage>

View solution in original post

5 REPLIES 5

You can change the HTTP method with an AssignMessage policy.

Hi @nitin.kotian

Use the <Verb> tag in Assign Message Poilcy to set <Set> the HTTP Verb in an Assign Message Policy.

<AssignMessage name="AssignMessage-3">
  <AssignTo createNew="true" type="request">request1</AssignTo>
  <Set>
    <Verb>GET</Verb>
  </Set>
  <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
</AssignMessage>

Thanks @Nisha Mallesh and @sudheendra1 Followup questions- So an incoming POST can be sent to the backend as GET which essentially means I need to read the request variables from my POST and put it into a querystring. I think we can create dynamic querystrings but need to check if I can do something like this /policy/{userid}/{emailaddress}/address where userid and emailaddress are between static values /policy and /address?


@nitin.kotian , Yes, You can do that. You can use ExtractVariable policy to extract request variables from post request & use Assign Message Policy to put into query string. For more details check the policy documentation. Our docs are pretty extensive. It should be few minutes work. Give it a try & keep us posted with policy / proxy code if you still have any queries.

Thanks @Anil Sagar I'll test it out. Thanks. Will reach out the community if I need any assistance. Thanks again.