Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


POST json returns 404

  • norman044

    When i try to send json data in the content field i get a 404 returned, i have checked the POST sent from a web browser using an http sniffer and it seems to be the same as what i try to produce, here's my code:

    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &writeCallback); //recieve data
            curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
            curl_easy_setopt(curl, CURLOPT_URL, auth); 
            curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_array); //send json file
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
    curl_easy_setopt(curl, CURLOPT_COOKIE, cookie_string);

    im not sure if im missing something? this is my output

    * About to connect() to www.xxxxxxx.com port 80 (#0)
    *   Trying xx.xxx.xxx.xx… * connected
    * Connected to www.xxxxxxx.com (xx.xxx.xxx.xx) port 80 (#0)
    > PUT /link/to/dir/ HTTP/1.1
    Host: www.xxxxxxx.com
    Accept: */*
    Cookie: XXXXX
    Content-Type: application/json
    Content-Length: 305

    < HTTP/1.1 404 404
    < Date: Sat, 04 Aug 2012 15:53:39 GMT
    < Server: XXXX
    < Content-Length: 0
    < nnCoection: close
    < Content-Type: text/plain
    * Connection #0 to host www.xxxxxxx.com left intact

    * Closing connection #0
    Press any key to continue . . .

    i have used x to mask my details and website.

  • norman044

    it appears in the json file im sending one of the values requires an "unsigned long long int" but libjson uses long int, is there any way of changing this?

  • norman044

    problem solved, int is not necessary i just used strings

  • The JSON_INT_TYPE can be set to long long.