How to make the POST request and made shown in trace section

Not applicable

I want to made the put request and send JSON to my end point and get response. the issue is that I always receive 4xx errors.

Here is my target endpoint, the service endpoint is http://109.166.244.140:9763/webRS/services/user/validateCredentials with POST method. What am i doing wrong? How can i pass JSON and make the POST request? Thank you.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
    <Description/>
    <FaultRules/>
    <PreFlow name="PreFlow">
        <Request>
            <Step>
                <Name>GetCredentials</Name>
            </Step>
            <Step>
                <Name>BasicAuthCredentials</Name>
            </Step>
        </Request>
        <Response/>
    </PreFlow>
    <Flows>
        <Flow name="userCredentials">
            <Condition>(proxy.pathsuffix MatchesPath "/validateCredentials") and (request.verb = "POST")</Condition>
            <Description/>
            <Request/>
            <Response/>
        </Flow>
    </Flows>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <HTTPTargetConnection>
        <Properties/>
        <URL>http://109.166.244.140:9763/webRS/services/user</URL>
    </HTTPTargetConnection>
</TargetEndpoint>
0 2 2,714
2 REPLIES 2

Hi Oleksandr Skoryi,

What I understood from your question is that you are trying to make a PUT request to Apigee , and forward the request as POST to target. If so then first you need to change the verb before sending the request to target from PUT to POST . You can use Assign Message policy in two ways to set the request verb of target endpoint as POST in userCredentials flow.

1. set the request.verb to POST as below

<AssignVariable>

<Name>request.verb</Name>

<Value>POST</Value>

</AssignVariable>

2. or set it as

<Set>

<Verb>POST</Verb>

</Set>

Also I see that the condition for the flow is request.verb = "POST", whereas if you are making PUT request to Apigee, the condition should be request.verb = "PUT"

Let me know if this resolves the issue.

It's difficult to anticipate the reason based on the information you provided here. In general a 4XX just indicates a bad client request - including issues with authorization, method not supported, input error etc. If you could share complete request (with and without apigee) it's easy to debug.