I am in the process of integrating with a third party app and this issue comes while integrating with one of their GET APIs. The API has some headers and params and it's working perfectly fine in Postman. However, the same request when formed in Java and executed with RestTemplate (exchange method) gives 422 unparsable entity. Where could I be going wrong and what could be done to fix this issue?
It really depends on the server end why it responds with that HTTP code.
Definition of 422 Unprocessable Entitycode from Mozilla website:
The HyperText Transfer Protocol (HTTP) 422 Unprocessable Entity response status code indicates that the server understands the content type of the request entity, and the syntax of the request entity is correct, but it was unable to process the contained instructions.
which means, the data is correct, and server understood it but it cannot process the request.
I suggested you try in RestTemplate using the same exact values tested successfully on Postman.
A screenshot on Postman and your some snapshot of your code on the headers and request params will help to debug further.
Make sure you don't mistake #PathVariable with #RequestParam.
Related
I'm using Spring Boot to consume API. For some APIs, it works but for some others it fails returning 500 Internal Server Error. For example, when consuming this API https://quoters.apps.pcfone.io/api/random it works, but https://reqres.in/api/unknown/23 returns 500 error. To what can this be due?
My code is simple:
restTemplate.getForEntity("https://reqres.in/api/unknown/23", String.class)
A request to the error-causing URL responds with a 404 Not Found status code. Please check if the server is serving on the given endpoint.
As for the 500 Internal Server Error, what's happening is that upon receiving the 404 from the server, your RestTemplate is throwing a RestClientException, which is being converted into a response with the status code: 500. You can add explicit handling for this using #ControllerAdvice, which will allow you to have more control over the response status.
Here's a reference for ControllerAdvice in Spring: https://spring.io/blog/2013/11/01/exception-handling-in-spring-mvc
I'm trying to make use of MailChimp's Automation trigger that activates when a subscriber's email ID is posted to an API endpoint:
(link)
Following the Workflow instructions, I'm using the following https://us19.api.mailchimp.com/3.0/automations/xxxxxxxxxx/emails/xxxxxxxxxx/queue URL provided via the Campaign.
I can successfully send an authenticated HTTP POST request (using this do_Post() method copied into my codebase), but am faced with a 400 error with a Content-Type: application/problem+json response. My JSON is incorrect and I'm not sure what the JSON should look like to trigger the above event.
I've tried a plethora of different cracks at the JSON - my latest attempt looks like {"unique_email_id":"e063dfcf4g"}. Every attempt at altering the JSON data still is returning me the same error above.
I've been wondering if I possibly need to set some more headers in the POST request, but this is beyond my area of expertise.
I appreciate the help and insights.
Here's an example of HTTP Basic Auth Postman request:
POST URL:
https://us19.api.mailchimp.com/3.0/automations/********/emails/********/queue
you'll get this when you create api based trigger automation campaign.
Authorization:
generate the api key from mailchimp dashboard and use that as password in postman authorization. put any username.
POST Body:
{"email_address":"tigerking#gmail.com"}
Read more about mailchimp API : https://mailchimp.com/developer/guides/get-started-with-mailchimp-api-3/
there's also a npm module for this https://npmjs.com/package/mailchimp-api-v3
I have recorded a script and running it. But I'm receiving the following error.
HTTP Status 405 - Request method 'POST' not supported in jmeter
I'm not sure whether it is script issue or coding issue.
Our application is installed on HTTPS but security certificate not yet installed.
Could any one please help me out.
It could be one of below
The endpoint you are requesting is not supported for POST, It may support only GET, Please change the method in Jmeter to GET or the method your url supports
The endpoint may expect proper CSRF token. It might mismatch with one you recorded. So Please extract CSRF token from previous request's response and use it. You can do via RegEx Extractor in Jmeter.
JMeter does support POST method so it may be due to:
Endpoint you're using doesn't support POST method (it expects other method(s) like GET, PUT, DELETE, etc.)
You're sending not properly configured request.
The most common reason is missing relevant Content-Type header. You can use HTTP Header Manager in order to send the relevant Content-Type header which is usually application/json for REST or text/xml or similar for SOAP.
See Testing SOAP/REST Web Services Using JMeter article for more information on API testing using JMeter.
You can also consider the following approach:
Use specialized Web Services testing tool like SoapUI or RESTClient to fire a request
Either use aforementioned tool or 3rd-party sniffer like Wireshark to capture the request
Configure JMeter to send exactly the same request
I am trying to use drive Rest API in my app by following the official quickstart documentation. I generated a SHA1 key, everything works fine but when I call drive API from android phone, I get 400 bad request.
How is this caused and how can I fix this?
HTTP 400 means that the server cannot or will not process the request due to an apparent client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
Could you please take a look at your HTTP request whether it is what you intended it to be?
I wrote a context.io 2.0 java client for : accounts,discovery, threads and messages operations to be used in my project (based on the available ContextIO Java client).
My code is at : https://github.com/dileepajayakody/isis-reputationbox/blob/master/reputationbox/dom/src/main/java/at/tomtasche/contextio/ContextIO_V20.java
While testing it, when I invoke the accounts request: https://api.context.io/2.0/accounts and discovery requests (eg: https://api.context.io/2.0/discovery?email=testemail#gmail.com&source_type=IMAP, I successfully get the desired response with a HTTP 200
However when I invoke the messages, threads, contacts requests by adding the account_id parameter in the request URL (eg : https://api.context.io/2.0/accounts/1234ff425ad/messages) I get an empty JSON array with a HTTP 403 Forbidden response.
When I try out the same request in the contextio developer console, I get the response without a problem.
I don't think it's something wrong with the way I sign the oauth request since it's the same way I sign for accounts and discovery requests for which I get the contextIO response properly.
Any help in resolving this error is much appreciated.
Thanks,
Dileepa
I don't think the issue is related to oauth request signing, since we normally return 401 or 404 messages for errors there.
The fact there's no body content with the 403 response leads me to believe your api_key does not own the account specified. If it did own it then we would include a json array with type, code, value parameters to help debug the issue. If you have two developer accounts then you may just be using the wrong one for this test.
I hope this helps. If not, please feel free to contact us at support#context.io.
Thanks!
Dan