We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
Please edit your post, select your code and hit ctrl+o to format your code. Make sure there is an empty line above and below your code.
Kf
Thanks kFrajer for that
i think your problem is that the two requests are separate things.
how does the GET know what the POST did?
Yep. I need need some kind of catch....
You will need to check the API... I am getting the same message here. Notice the post returns true so it seems to be working. You should either check the documentation or contact the company providing the resources to verify your request.
Kf
same problem here. did anybody fix this?
Same question, different poster, bit more detail here:
https://forum.processing.org/two/discussion/22588/http-requests-cookies-sptrans-olho-vivo
working, i think
https://forum.processing.org/two/discussion/comment/98046/#Comment_98046
Thanks man!!