Trying to curl basic stuff but std.net.curl isn't cooperating:

curl "https://www.googleapis.com/youtube/v3/channels"; -G -d part=contentDetails -d forUsername=test -d key=somekey

import std.stdio;
import std.net.curl;


int main(string[] argv)
{
        auto http = HTTP();
        http.caInfo("cacert.pem"); // cacert.pem installed in the bin dir
        http.handle.set(CurlOption.ssl_verifypeer, 1);

auto content = post("https://www.googleapis.com/youtube/v3/channels";, ["part" : "contentDetails", "forUsername" : "test", "key" : "somekey"], http);


    return 0;
}

I either get the error

Unhandled exception: std.net.curl.CurlException Peer certificate cannot be authenticated with given CA certificates on handle at std\net\curl.d(4343)

or, when verifypeer is 0,

Unhandled exception: std.net.curl.HTTPStatusException HTTP request returned status code 404 (Not Found)

But the command line version works fine. (of course, if you want to test you must use a valid key and youtube user name.

This is one of the reasons I hate D ;/ I've spent more time trying to get std.net.curl to do something that just works from the command line.

Reply via email to