0

I am not able to send request payload to my POST service from WSO2.
On rest console, my service is working.
From WSO2 server I am able to do curl to my server with successful response.

here is my API configuration enter image description here
Payload to send:

{"query":"Hi I am a POST query parameter"}

My server is receiving {} as request payload.
It expect RAW body in JSON (as above) in payload.
I have tried all combinations for Parameter Type, but still not able to send payload to my server from WSO2.

How can I do this?

EDIT 1 I have tried all possible ways of sending data including following. Am I doing something wrong here???

enter image description here

and

enter image description here

From both I get error that my payload is empty or incorrect!!

Edit 2
I am able to connect with Java based services but not with Python based services.
Do I need any special settings on my python server?

Community
  • 1
  • 1
Abhinav Tyagi
  • 5,158
  • 3
  • 30
  • 60

3 Answers3

0

enable wirelogs and check following

  1. payload is coming into the API manager (swagger -> AM )
  2. Payload is going out from api manager (AM -> backend)

Also check the request headers coming in and going out and compare them with the stuff from curl request (successful request)

Chamila Adhikarinayake
  • 3,588
  • 5
  • 25
  • 32
  • how can I see if payload is coming into API manager, and it is sending it out to my server? Logs are bit complex to look into. I see my payload printed there but not sure if its going in or out or both !! – Abhinav Tyagi Jun 23 '16 at 06:42
  • In the provided link, it describes how to read the wirelogs. It has " >>" and " <<" signs to indicate which direction the message is going. Do a one request to the server and check the flow base on the arrow signs – Chamila Adhikarinayake Jun 23 '16 at 07:04
  • I can see my payload with both >> and << but not successful with my response :( please see logs below – Abhinav Tyagi Jun 23 '16 at 07:26
  • TID: [-1] [] [2016-06-23 13:04:30,063] DEBUG {org.apache.synapse.transport.http.wire} - >> "[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [-1] [] [2016-06-23 13:04:30,068] DEBUG {org.apache.synapse.transport.http.wire} - >> "{[\n]" {org.apache.synapse.transport.http.wire} TID: [-1] [] [2016-06-23 13:04:30,068] DEBUG {org.apache.synapse.transport.http.wire} - >> "'query':'feeling super happy'[\n]" {org.apache.synapse.transport.http.wire} TID: [-1] [] [2016-06-23 13:04:30,068] DEBUG {org.apache.synapse.transport.http.wire} - >> "}" {org.apache.synapse.transport.http.wire} – Abhinav Tyagi Jun 23 '16 at 07:26
  • TID: [-1] [] [2016-06-23 13:04:30,214] DEBUG {org.apache.synapse.transport.http.wire} - << "{[\n]" {org.apache.synapse.transport.http.wire} TID: [-1] [] [2016-06-23 13:04:30,214] DEBUG {org.apache.synapse.transport.http.wire} - << "'query':'feeling super happy'[\n]" {org.apache.synapse.transport.http.wire} TID: [-1] [] [2016-06-23 13:04:30,214] DEBUG {org.apache.synapse.transport.http.wire} - << "}[\r][\n]" {org.apache.synapse.transport.http.wire} – Abhinav Tyagi Jun 23 '16 at 07:27
  • In wire log check what is the response you are getting from back end to gateway. Compare the request from gateway to backned with the request used in curl command – Jenananthan Jul 14 '16 at 07:23
  • Do you have an access log in your python service side? If so, first make sure the request from APIM is reaching the python service. If yes, then debug the python service. I feel like no response is reaching the APIM from your python service. – Amila Maharachchi Jul 19 '16 at 07:20
  • @ChamilaAdhikarinayake I have updated my question http://stackoverflow.com/questions/38451304/wso2-api-manager-compatibility-with-python. Can you look into that as well? My issue is still not resolved. Content-Length comes 0 – Abhinav Tyagi Jul 26 '16 at 11:41
0

I am using Flask and I am afraid Flask can not deal with this issue currently.

I could reproduce this issue, the message send to back-end correctly, but Python only handle message until timeout.

Python Flask cannot receive post request from WSO2

The work-round may be using Java or Python get method.

Lu Ming
  • 632
  • 4
  • 20
0

I solved this problem by using apache to proxy this request. I think this is related with wsgi. Processing chunked encoded HTTP POST requests in python (or generic CGI under apache)

ProxyPass / http://localhost:8001/
ProxyPassReverse / http://localhost:8001/
Martin Evans
  • 45,791
  • 17
  • 81
  • 97