Callout failed for invocable action in flow - json

I am trying to send an API request to the external service using flow in salesforce but when I debug my flow it returns the below error
Error Occurred: Callout failed for invocable action testing3.post-vacancy-id. Expected declared response media type application/json, but got application/problem+json; charset=utf-8 for operation post-vacancy-id and service testing3
I have not specified the content-type in the header (cause I don't know how to define that in the header in flow) but I found that it will take the default content-type as application/JSON and also I have checked the body of the API request it is work fine when sending it from the postman.
I have searched regarding this but didn't find anything on the web, any help will be appreciated here.
thanks!!

Related

Rest call failed with client error, status code 406 NotAcceptable

When I test with Advanced Rest Client(Arc) all nine API calls to REST API works fine.
I use method Get with two headers the first is Authorization Bearer
the second one is Content-type application/json. It works even if I remove
header Content-type application/json
Here is a screenshot of the response from Arc. This same REST API call give error from Azure Data Factory(ADF).
Sceenshot from Arc
I call nine REST API from Azure Data Factory(ADF) with the same base url but different Relative URL.
Out of these nine 6 works perfect.
When I use Azure Data Factory(ADF) I use additional header
Authorization Bearer #{activity('GetToken').output.access}
What is strange is that the exact same call from Arc works fine but I get error when I call from ADF. Note also that I get the exact same error if I remove the additional header
Authorization Bearer #{activity('GetToken').output.access}
I mean that the code in REST API doesn't know if the call is comming from Arc or ADF.
Note also the the error is from the source side so my call to REST API with method GET
can't be handled by the REST API code for some reason.
According to the documentation for the REST API it says that
Headers Content-type application/json and
Authorization Bearer
I tried to add a second additional header in ADF Headers Content-type application/json
but I get REST connector ignores any "Content-Type" header specified in additional headers when request body is empty.
I have tried to find any sensible information about my error but there no one that have had any similar. What I find very strange is that 6 Rest API calls works fine and the json that we receive when using Arc is valid.
I don't realy understand the error message when saying
Requested format \u0022application/json\u0022 is not supported
Supported MIME types are \u0022application/ld+json\u0022
Here is the complete error message I get Screen shot of error message for ADF
Your response data is JSON LD (Json linked data). Hence you are seeing this error.
To avoid this error use Content-Type header value as application/ld+json.

Recently I'm having CORS problems only in Google Chrome

Having some major CORS problems with Google Chrome lately:
Access to XMLHttpRequest at '...' from origin '...' has been blocked
by CORS policy: Response to preflight request doesn't pass access
control check: It does not have HTTP ok status.
The weird thing is that the request works perfectly on Mozilla Firefox.
I tried to add different headers to the server including:
Access-Control-Allow-Headers: Content-Type,Authorization,X-Requested-With,Accept,Access-Control-Request-Method,Origin,Access-Control-Request-Headers
Access-Control-Allow-Methods: GET, POST, DELETE, PUT,OPTIONS,HEAD
Access-Control-Allow-Origin: *
Also before the "CORS Block" there's an OPTIONS request method Google Chrome sends my server but here i get a 500 server error:
javax.servlet.ServletException: A MultiException has 4 exceptions.
They are:
javax.ws.rs.ProcessingException: Error creating a JAXBContext for wadl processing.
java.lang.IllegalStateException: Unable to perform operation: create on
org.glassfish.jersey.server.wadl.internal.WadlApplicationContextImpl
java.lang.IllegalArgumentException: While attempting to resolve the dependencies of
org.glassfish.jersey.server.wadl.processor.WadlModelProcessor$OptionsHandler
errors were found
java.lang.IllegalStateException: Unable to perform operation: resolve on
org.glassfish.jersey.server.wadl.processor.WadlModelProcessor$OptionsHandler
org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:432)
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
com.isyndix.rest.CORSFilter.doFilter(CORSFilter.java:40)
Does this have anything to do with it?
Thanks in advance for your help and time.
Cheers!
So apparently it had something to do with the OPTIONS-preflight not being handled right in the server back-end.
I have implemented the OPTIONS method in the REST endpoint:
#OPTIONS
public Response options() {
return Response.ok().build();
}
Keep in mind this is not a very good way of handling the problem because you need to implement this for every endpoint in your API.
But I didn't find a better solution and this works for me.
Cheers!

Post request and get response robotframework

I need to send POST request and get json from it.
Create Http Context emopstest.pdc.org http
Set Request Header Content-Type application/x-www-form-urlencoded
Set Request Header Authorization Basic bG9naW46cGFzcw==
${dict}= Create Dictionary app_ids=18 where=ROWNUM<=2000
${value}= Stringify Json ${dict}
Set Request Body ${value}
HttpLibrary.HTTP.POST /auth_srv/services/auth/1/json/get_hazards
Show Response Body In Browser
Response Status Code Should Equal 200
${result_text}= Get Response Body
${result_json}= Parse Json ${result_text}
But this code returns to me 404...
What is wrong?
The 404 means that the server couldn't find the resource you requested. Usually that means the URL was wrong. Depending on how the server is configured, it could also mean that your authorization is wrong (ie: some applications will give a 404 in the case of bad authentication, so that an attacker isn't given a clue that the credentials are incorrect)
The server logs should have information that will help you track down whether you have an incorrect URL or that the server has a bug.

Using file as payload in Advanced REST Client

I'm trying to work with the Advanced REST Client of Google.
I installed the extension, and I can work with it.
Now I wanted to use a JSON-file as input for my payload.
The JSON-file looks as follows :
{"UserName":"", "UserPassword":"","SetDebug":true}
The Content-Type is set to application/json.
But when I try to send the request I get the following error:
{
"Message": "The request entity's media type 'multipart/form-data' is not supported for this resource."
}
What am I doing wrong? Can anyone help me?
The ARC seems to override your Content-Type selection sometimes, changing it to multipart-form-data. If you select Files for the body and pick a file, it shows a message saying:
The Content-Type header will finally be changed to "multipart/form-data" during the request.
When you submit the request, it does exactly that: changes the Content-Type header. You can confirm this by looking in the Request Headers part of the output display.
I don't know if there's any way to stop it doing this :(-

Testrail Bad Request error when using add_run method in API

I'm attempting to use the add_run API method to create new test runs on my testrail server. I am using RESTClient to test the command.
The request is POST index.php?/api/v2/add_run/1
(I have a project with id 1)
As request headers I am using Content-Type: application/json and Authorization: Basic USERNAME:PASSWORD_BASE64
request body is:
{
"name":"name",
"suite_id":1
}
Upon sending the request, I receive a "400 Bad Request" Response with the error message:
{"error":"Content-Type header invalid (use Content-Type: application\/json)"}
Since I am in fact using Content-Type: application/json as a request header I have no idea why I am getting this error or what it means. Anyone have any ideas?
one of the TestRail developers here. It's very likely that you didn't submit the Content-Type header correctly, could you please share the source snippet you used to send this request?