HTTP Request

Hi!

Im trying to request some information from a public transportation web site. I'm using the HTTP Request Library. And it have to POST an authentication for then a GET to fetch the information.i'm getting a True return from the POST authentication... but a message : authorization denied.

Any Help?

import http.requests.*;

public void setup() 
{
    size(400,400);
    smooth();
  String searchLinha = "8000";


    PostRequest post = new PostRequest("http:" + "//api.olhovivo.sptrans.com.br/v0/Login/Autenticar?token=4af5e3112da870ac5708c48b7a237b30206806f296e1d302e4cb611660e2e03f");



  GetRequest linhas = new GetRequest("http:" + "//api.olhovivo.sptrans.com.br/v0/Linha/CarregarDetalhes?codigoLinha");

  post.send();
  linhas.send();

  System.out.println("Reponse Content: " + post.getContent());
  System.out.println("Reponse Content-Length Header: " + post.getHeader("Content-Length"));

  System.out.println("Reponse Content: " + linhas.getContent());
  System.out.println("Reponse Content-Length Header: " + linhas.getHeader("Content-Length"));


}

the Console:

Apr 25, 2017 3:37:39 PM org.apache.http.impl.client.DefaultRequestDirector handleResponse
WARNING: Authentication error: Unable to respond to any of these challenges: {}
Reponse Content: true
Reponse Content-Length Header: 4
Reponse Content: {"Message":"Authorization has been denied for this request."}
Reponse Content-Length Header: 61

Answers

Sign In or Register to comment.