Configure Webservice

Asked

Viewed 46 times

0

I’m having difficulties to configure a POST method, I’m implementing the integration with the payment platform Gerencianet, their support returned me the following message in a call:

Dear, please try to rate the header of your query file to token. As we do not know your implementation files, besides the fact that we cannot interfere for security reasons, I will try to help you to find an appropriate solution.

I believe the error refers to the call not to include the statement "Content-Type: application/json". http://prntscr.com/e2megi

HTTP 415 means that the server does not understand the media format of the request. In your controller you are specifying that you accept JSON, but you did not say if the request indicated that the body is in this format. Just because you put the data in JSON format, it does not mean that the server will recognize it, you have to index it in Content-Type header.

/**
 * Método que recebe o Token do Gerencianet via POST
 * 
 * Então é passado para o método que realiza a consulta via Token
 * e atualiza o Objeto no BD
 * */
@POST
@Path("/RecebeToken")
@Consumes(MediaType.APPLICATION_JSON)
public void recebeToken(String token){
    System.out.println("Token Recebido: "+token);
    //CheckOut.consultar(token);

}
  • The question seemed confused and I did not understand it very well. Anyway this strange the fact that although the CONSUMES nomenclature specifies that the function will receive a JSON object the function itself receives a STRING. The function receivedToken should be declared like this: public void receivedToken( Jsonobject token )

  • Well, I did as you suggested, it looked like this: @POST @Path("/Receivedken") @Consumes(Mediatype.APPLICATION_JSON) public void receivedToken(Jsonobject token){ But I got the same error. Well, the context is as follows. I get a billet for payment on this platform (Gerencianet) and for me not to be "consulting" the situation of Boleto they make a "POST" in my webservice when the status of Boleto is changed passing me this token, then only then do I make a consultation and see what has changed.

  • First you have to know, which specification of the webservice you will consume and then make your client as per the specification, I made a payment integration in November, I opted for iugu, because none of the most famous on the market had appropriate documentation to make the integration, even with the documentation is painful, because most implementations do not follow the specification to the letter, this generates problems and conflicts

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.