send POST request in wso2 api manager 4.1.0 - django

I want to send a POST request with a body in WSO2. actually, I have a Django rest framework with some APIs and want to send requests in WSO2 API manager. it's all OK for GET, DELETE but when I want to POST some request I'll receive a bad request from Django server.
Django server is running on http://localhost:8000/user-api/users/
in wso2 api publisher api's URL is : http://localhost:8243/users/1.0.0
endpoint in wso2 is : http://localhost:8000/user-api/users/
the below picture is what I receive when I send GET request:
I send POST request with this json as body:
and here is what I receive when I send POST request:
Everything is ok when I check the server's URL in my browser.
UPDATE:
when I use my Django server as a gateway for WSO2 everything is OK but when I use default WSO2-Gateway everything goes wrong.

I'm not clear about what this question is really asking. But I feel this is generally asking how to debug this situation. I apologize if I got that wrong.
To start debugging a problem with a WSO2 server in the mix there are some common things to think about:
If this is a local or development region can I use http, instead of https, so that I can view things as plain text during debugging activities.
For the Enterprise Integrator products there is a test feature for back end endpoints in the admin Console. This can often be helpful to ensure communication can happen. It's like a simple ping.
Check inside the trace.log to see if there is anything helpful for you.
For APIM use the Test a REST API feature to try out the backend to see if that works before coming in the front door of the server.
For WSO2 products if reviewing logs aren't giving enough information then you can use the Wirelogs to enable you to view every piece of information that goes in and out of the WSO2 server. These are formatted roughly like Wireshark logs but the output is inside of the wso2carbon.log file. The key here is getting used to the >> and << to determine if the log entry is going out of or into the WSO2 server.
If you still can't find the issue then you might need to go down to reviewing the data as it goes across the wire. This is a bit complex at first but you'll quickly get the hang of it. (Hint: This is extremely helpful for trouble shooting JMS communication.)
On linux you can use tcpdump to write data to file and then open it with Wireshark. Windows has a similar system.
For tcpdump you need to use the interface name. It's often like eth0. You can find t using ifconfig. It's the value: before the flags.
Example tcpdump capture:
tcpdump -s 0 -I {interfacename} -W 30 -C 50 -w wsoei-01-07192022.pcap -Z root
tcpdump -s 0 -i ens192 -W 30 -C 50 -w wsoei-01-07192022.pcap -Z root
Once you have the pcap file captured you then use Wireshark to open it. And there you have it you can see everything that went across the wire. Once you have that you can start to see at what point things are breaking down.
Conclusion
If you zoom in close enough with your research you will eventually find where the breakdown is.

Related

call to external API is getting blocked on Google cloud compute engine

I am trying to connect to an external API from .net.
It is working as expected from other machines.
But we are not getting any respond from the API call when trying from the server.
We have tried accessing the api url on the browser and it failed with the same no response error.
This is what we have done so far.
We have checked VPC firewall and tried some firewall rules ( Google Cloud firewall) and made sure that there is no blocking to this API.
We have checked Windows firewall and it is switched off now. We also made sure that there is no rules to block this API. However to test it further, we are now switched it off.
Checked that we are able to connect to other websites from the server.
Checked whether we can access the API from other machines. We are able to connect to the API successfully using the tokens from the server.
We have also installed Wireshark to analyze the incoming and outgoing packets from the server. From this analysis, we were able to find that there are network packets sending to this API and it is trying the retransmits the packets, but there is no acknowledgement packet received. This might be of the below two scenarios.
The acknowledgement packet sent from the API server lost in transition.
The data that we have sent from the server to the API lost in transition.
Contacted the API technical team and made sure that the IP is not getting blocked on their end.
Tried contacting Google Support but we have not received much help from them as ours are in "Bronze plan"
This was working without any issues from the server in the past. Not sure what is happening now.
Thank you in advance for all the helps.
Thank you Jeffrey and Patrick for your kind reply. As suggested by Patrick, I am adding here my comments as an answer to close this post. We were able to identify the issue from the wireshark analysis. It was the API provider who was blocking the IP. We have contacted them again with the results and they confirmed this. Thank you very much.

Sending large payloads via WSO2 ESB

I'm trying to do some load testing on the WSO2 ESB, and I have a SOAP message with a large payload that I'd like to send (10+MB, sometimes reaching 50 inbound, and sometimes even 300 outbound).
I'm using curl to send the messages, first to the backend SOPAUI service. This goes through fine. However when I send the message via a proxy service on the ESB, curl fails to finish uploading the file, and gets slower and slower as the upload progresses. The logs from the ESB do not seem to be reporting anything useful.
I have set the timeout on this to 20 minutes, and it still does not complete. Turning on MTOM has no effect, and I am using a simple passthrough proxy. The proxy service functions fine with small message sizes.
What else can I look into to get this working? If it is indeed possible.
You could try to configure Message Relay
in repository/conf/axis2.xml, you configure :
org.wso2.carbon.relay.BinaryRelayBuilder as the messageBuilder's class associated with your contentType (text/xml for exemple if soap11 of application/soap+xml with soap12)
org.wso2.carbon.relay.ExpandingMessageFormatter as the messageFormatter's class
Have a look there : https://docs.wso2.com/display/ESB481/Message+Relay
Turned out I had to switch to using the NHTTP transport rather than the Passthrough transport, thanks to this question here for prompting looking into this: WSO2 ESB unknown error code 102511
Requires an edit in carbon.xml, detailed in the accepted answer from the link above.

Redirect outgoing HTTPS request to an HTTP fake service?

My title might be overly specific - I'm having trouble formulating the question, since I haven't dealt with network administration a lot, and especially not SSL / HTTPS. In other words, the answer to "Why haven't you done . . ." is like to be, "I don't know much about ...."
I am testing, and the System Under Test (SUT) is a web service calling into the Facebook API using https://graph.facebook.com.
I have a test server set up on a remote machine that will serve pages to http://graph.facebook.com. I can use the hostfile on the SUT server to redirect requests to http://graph.facebook.com to the test server. This works fine when I then type:
curl http://graph.facebook.com
The test server receives the request, and serves back the expected page.
However, as mentioned before, the SUT isn't using the HTTP site, but the HTTPS site for the Facebook API (naturally). Is there any way I can intercept the outgoing request and redirect it to the HTTP service that I'm running on the other site? I'd like to be able to type:
curl https://graph.facebook.com
and have it be redirected to the fake Facebook service I'm running on the test server. I can configure the servers at both ends.
If this is very difficult, I might also want to put in a feature request for the ability to change the URL for the Facebook API requests. However, I think the dev is using a pre-existing Facebook API module, and this might not be straight-forward. (Okay, I got curious and checked . . . a quick investigation suggests that the API supports data injection of the code that handles the actual HTTPS requests, so he'd have to implement his own version of the interface so that he could pass in a configurable URL that I could set from outside of the code - but I'd still rather not distract him unless it's really necessary).
I'm using an asis-server on port 80 to fake the Facebook responses, if that is relevant.
The solution we ended up using was a service on the test server that intercepted the HTTPS requests and redirected them to the HTTP service. Our ops person used nginx for this.
We're still not sure if this will work as a mock for the SUT - it depends on if the SUT is verifying the certificate information or ignoring it. I still might need to ask the developer to implement a feature to support mocking.

How can I get Fiddler to display information about a web service request made from my ASP.NET code behind?

I have an ASPX page. When the page is loaded there is code in the code behind that uses an API. The API makes an HTTPS call out to a third party, commercial web service. I am trying to troubleshoot why the API calls are not working properly. Apparently the API actually constructs an XML request that is sent out over HTTPS to the web service. I've been told by the support rep that I need to provide them with the XML that is being sent. The only way I can figure out how to get the XML is to use a tool like Fiddler to see what is being sent out. So how can I use Fiddler to see the contents of the XML request that is being sent from the server out to the web service? I am running everything directly on the server but all I am seeing is the GET request for the ASPX file itself. I am not seeing anything in relation to the HTTPS request that the server code is sending out to the web service. I have not used Fiddler much so I am hoping that maybe I just don't have it set up right to monitor that traffic.
Corey
After mucking around with it a bit I found this post: Why isn't fiddler capturing request when invoking XMLRPC from iis?. That seemed to do the trick! Basically it sounds like the default proxy settings in Win7 are on a per user basis. So I went in and changed the identity of the AppPool for my site to a local user (Administrator) and then it worked great. I started up Fiddler. Then I started up my ASP.NET app and then when I loaded the page I saw the request that went out to the web service from my code behind! Yay!

Fiddler - error when simulating modem speeds with Web Services

I have an application that pulls data from several web services.
The application is correctly using fiddler as a proxy for all these web service requests, and everything works as it should.
I would like to simulate the web services servers being slow, so I enabled "Simulate Modem Speeds" in fiddler (without modifying the default rules file). Now most of the responses I get back are:
ReadResponse() failed: The server did not return a response for this request.
If I disable the "Simulate Modem Speeds", everything works fine again.
Is there a way to get this to work, or a better way to simulate a web services response being slow?
Uh, it certainly sounds like your webservice is configured to timeout if it doesn't get a given request within a certain period of time, suggesting that the simulation has, in fact, turned up the sort of problem you'd want to be testing for.
If you want to adjust the "slowness", edit the Rules > Customize Rules file. Search for modem to see the latencies.