400 Bad request while consuming a rest service with POST method? - mule4

I'm getting http requestor connection problem with POST:request a bad request even though I'm configuring properly. I'm sending json payload in the body and Bearer token in headers parameters with content type, I can evaluate the token and payload properly but still getting as a bad request when I tried to hit the direct URL as well, and I tried the trigger in postman with the same token generated in mule where I'm getting the success response but while using the same service within mule getting as bad request, I'm using http connector plugin version 1.7.1 in pom.xml.. Is there any problem with the dependency? can anyone help me with this?

If you are successful doing the request in postman then the HTTP request in your Mule application has to need some adjustments to make it match the postman request. Compare them carefully to make them match.

Related

How to make a request to a URL with gRPC Transcoding Syntax with a standard POST request?

I am attempting to use the endpoint https://firestore.googleapis.com/v1/{parent=projects/*}/databases with more data needed per the documentation on Google's docs.
The goal is to be able to make this request with a standard http utility such as cURL.
I have attempted performing the request manually through the GUI with the Chrome network tab open, and I saw a request being made: https://firebasedatabase.clients6.google.com/v1beta/projects/XXXXXXXXXX/locations/us-central1/instances?databaseId=my-database&validateOnly=true&alt=json&key=secretkey
Per trial and error on another endpoint, I have found that the key parameter can be replaced with a Bearer Auth token in the header. Other than that I am at a dead end.

Cannot reproduce SOAP requests sent by an .exe file in Postman or SoupUI

I tried to reproduce a bunch of SOAP requests sent by an .exe file in Postman but the API end point does not send back the correct result.
I constructed a request exactly like the one captured with Wireshark, but the response is not correct.
What seems to be the problem? What am I missing?
Update:
I just tried to send these request using SoapUI instead of Postman and with SoapUI the response is a SOAP response so it seems more correct, the endpoint still doesn't send back correct result, but at least the response is a SOAP response now.
Apparently Postman messes up the SOAP request in some way.
Solution:
I created a soap service with SoapUI and used the wsdl.xml file provided by the web service
SoapUI automatically generated all operations/requests defined in the wsdl.xml
I sent these auto generated requests made by SoapUI and they worked.
So I compared these requests with the ones I was sending and realized the syntax (xml body of the request) of these auto generated requests was different than the ones described in the web service doc.
but there are still some weird things that I don't understand, like the requests I captured with Wireshark had the same xml body as in the Doc described but they were successful responses.

Partial Response received from Apigee

The flow is SAP NWAS 7/Java AS ---> Apigee On Premise--->Apigee OnCloud -----> Backend. and back.
Backend is posting a response of appx 17 MB back. I have streaming enabled both on cloud and on premise Apigee. But the sap NWAS client states that only partial response is received .
When we invoke from POSTMAN however, we are getting complete response.
Please suggest where the problem can be?
Since Postman works fine for you, it seems like it might be a problem on the client side. So, it's possible that the client requires more info on the response in order to be able to display the content e.g. Content-Type header. Another way to troubleshoot this issue is to send a cURL command to the resource in Apigee and store it in the filesystem to validate that not only Postman can parse the response. e.g.
curl http://yourresourcehere/images/12344 > img12344.png

Can't get authentication token from web api 2

I am new to Web Api 2. I am trying to build a project to explore token authorization. I created a new project in VS 2013 and selected the WebApi2 template and used Fiddler to emulate http requests. I didn't change anything in the template, just ran it as it was and tried to play with it with Fiddler. I successfully created a user by issuing request to /api/account/register but I can't login by issuing a POST request to the /Token endpoint. The request is:
http://localhost:YYYY/token?grant_type=password&password=admin123456&username=admin
(i also tried to pass the parameters as a json object in the request body).
I get back this:
{"error":"unsupported_grant_type"}
From other posts such as ASP.NET WEB API 2 OWIN Authentication unsuported grant_Type I learned that I needed to enable CORS for web api and at the token endpoint, but that hasn't worked for me.
Are you sure that you are sending POST request message and not GET?
If you simply go to the URL with query string (or open connection to this URL from your code) you are sending GET message by default. It's not what WebAPI with "/token" path is listening for.
If you are calling web service from same place, CORS is not needed. The error "unsupported_grant_type" could be in the format of the data you are passing server in post action.
Try sending with Content-Type application/x-www-form-urlencoded

Custom HTTP method at Mule HTTP point

I use Mule as REST API <-> AMQP.
And I have to send custom Request Method: "PRINT", but I'm receiving:
Status Code: 400 Bad Request
The request could not be understood by the server due to malformed syntax.
Do you have any ideas how I can add custom HTTP method to Mule?
Unfortunately, because of this validateMessage() method here Mule rejects any method not listed here :(
I guess you need to open a bug with MuleSoft, asking for the capacity to configure extra methods, and in the meantime create a patch for the transport.

Resources