Java Spring Eclipse Tomcat - RestTemplate, Consume a HTTPS API - spring

Im using tomcat 8.5 with RestTemplate to consume iFood API, but i always get 500 error.
My localhost is already using a keystore generated file and configured with toncat.
With other api that uses only HTTP im having no problem.
But i cant make the iFood api with HTTPS work.. IF some one can help me.
Note: I can get the token, but when trying to use eventpolling endpoint i just get the error 500.

Thanks for all the comments, but i found the error.
The problem was that in the iFood API endpoint description, it has a char code inside the url.
The exemples use it normaly, calling from Postman no problem, but when using on Tomcat the char code generates a url error, unfortunately, with no feedback or usable error mesage.
Changing the char code to the corresponding character the problem was solved.

Related

Forbidden 403 Access URL API in Laravel

Good afternoon, let me ask
I created a service API using Laravel, but one of the API urls when I sent the response parameter was 403 or Forbidden. even though before it was fine, it worked smoothly. And I raised it to the server instead it became Forbide. Anyone know why? thank you for answering
If it is ok on local and getting a forbidden error on the server, the problem might be caused by the webserver application. please take a look at this link.

Using Rate Limiting doesn't add Header to response and gets CORS error in client

I'm trying to adapt this tutorial to my server using the Bucket4j Spring Boot Starter.
I'm using an application.properties file.
I can limit the api queries with no problem, but the client doesn't get a 429 error, on the client I get a CORS error.
I figure this is because I'm not adding a header to my server response when I'm limiting the api queries, but is there any way to add this throught the application.properties template?
On the official documentation there is a value called "bucket4j.filters[0].http-response-headers.<MY_CUSTOM_HEADER>=MY_CUSTOM_HEADER_VALUE" but I can't figure how to use it, did anybody use it?
Thanks
You can avoid CORS errors by adding the proper header:
bucket4j.filters[0].http-response-headers.Access-Control-Allow-Origin="https://<clientUri>:<clientPort>"
and if you are using some form of authentication you may want to also add this:
bucket4j.filters[0].http-response-headers.Access-Control-Allow-Credentials=true

Endpoint Server GraphQL (overblog-GraphQLBundle) Not support Method POST

For 3 Days, my project which worked perfectly locally, once put on the production server.
GraphQl requests are a failure with the error "[Error: Network error: JSON Parse error: Unrecognized token '<']" and after log analysis it is a 404 error because the route was not found.
After investigation via the GraphQl Atlair client for chrome by changing the method to GET to make my GrasphQl requests, the error everything works.
my question is how to work the POST method?
I really need to use the METHOD POST for mutations
Thanks everyone
Very cordially
You forgot to add a trailing slash to your GraphQL endpoint URL.
Related issue (solved): https://github.com/overblog/GraphQLBundle/issues/669

Spring RestTemplate 404 error for large POST request to .NET Core REST api

I am trying to make a Java (Spring) application which invokes a REST api in a .NET Core application. Everything seems to work in the general case, but now that I am making a POST with an XML string which takes up 80 megabytes on my system, the RestTemplate produces a 404 error code saying "Not found". I have tried to remove the POST size limit in both the .NET Core application (by using the DisableRequestSizeLimit attribute in the API controller) and in the Spring configuration (by setting the variable spring.servlet.multipart.max-request-size to 200MB in application.properties). Neither of it seems to work. Is there some way to fix this? I am willing to use an alternative to the RestTemplate, if that would make sense. I am using the exchange method of the RestTemplate object.
Not found is a general error, if the problem would be sending the request, other problem will happens. I highly recommend you to test the rest api with another tool, like Postman or Insomnia. After that works with the tool try with your client application.
Clarification:
spring.servlet.multipart.max-request-size is for api in your Spring application, no for requesting another services.
Due to Milton BO's answer, I made a request in POSTMAN, which gave me a more detailed error response from the ASP.NET Core app. And it told me to change the maximum allowed post size in the web.config (or appplicationhost.config) file for IIS Express. Furthermore, I am now using the Kestrel server instead of IIS Express, so the DisableRequestSizeLimit attribute now works as expected.

SSL Certificate Match Error while calling Google Places API

I have been using Google Places API inside my application. The client code is written in Java. It was working fine till couple of weeks ago and suddenly it started throwing following exceptions while making API call:
javax.net.ssl.SSLException: hostname in certificate didn't match: <maps.googleapis.com/209.85.175.95> != <*.googleapis.com> OR <googleapis.com> OR <*.googleapis.com>
I am using following URL for making API call : https://maps.googleapis.com/maps/api/place/search/json?
Also tried with different Google API keys generated from Google API console.
Can someone please point what I am missing here?
Many thanks
I used the latest Google API (version 1.13.2) which support better SSL options:
ApacheHttpTransport.Builder transport = new ApacheHttpTransport.Builder().doNotValidateCertificate().build();

Resources