1

I am sending the following request via my browser

https://www.overpass-api.de/api/interpreter?data=[out:json];area[name=Nicaragua];(node[aeroway=aerodrome][aeroway=aerodrome](area);way[aeroway=aerodrome][aeroway=aerodrome](area);>;relation[aeroway=aerodrome][aeroway=aerodrome](area);>>;);out meta;

Which, if you try, will return a valid json.

However, if I try to send it via the curlpp driver in my code, I am getting a "bad request" page in return. The code is the following:


#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>

int main() {
    std::string url = "https://www.overpass-api.de/api/interpreter?data= 
    [out:json];area[name=Nicaragua];(node[aeroway=aerodrome] 
    [aeroway=aerodrome](area);way[aeroway=aerodrome][aeroway=aerodrome] 
    (area);>;relation[aeroway=aerodrome][aeroway=aerodrome](area);>>;);out 
    meta;";
    std::cout << url << std::endl;
    curlpp::Cleanup cleaner;
    curlpp::Easy request;

    request.setOpt(new curlpp::options::Url(url));

    std::cout << request << std::endl;


    std::cout << curlpp::options::Url(url) << std::endl;
    return 0;
}

Yet if you try with any other url, it would work... Does curl only accept a certain string formatting ?

trexgris
  • 362
  • 3
  • 14
  • 1
    Compare the headers that curl is sending with the headers your browser is sending. – john Apr 07 '19 at 21:24
  • @john in both cases, it should be sending a GET... How would that be different ? I think its mostly the fact that curlpp only accepts URL that are already encoded isn't it – trexgris Apr 07 '19 at 22:16
  • HTTP requests also include headers. I'm guessing that your browser is sending a different set of headers than CURL. This is a different issue to GET vs POST. – john Apr 07 '19 at 22:18

0 Answers0