Home > Blockchain >  Getting error "No JSON provided" from Ogre when using post, but when use online converter
Getting error "No JSON provided" from Ogre when using post, but when use online converter

Time:01-19

I'm troubleshooting an issue trying to use Ogre to convert a GeoJSON to a Shapefile.

I was trying using php curl_exec, and also with Postman, and get the same response with each:

{
    "error": true,
    "msg": "No json provided"
}

However, when I paste the json into their web tool here, it successfully converts: https://ogre.adc4gis.com/

My php code looks like this:

           $posturl = "https://ogre.adc4gis.com/convertJson";
           $params = array('json'=>$geojson);
           $ch = curl_init();
           curl_setopt($ch, CURLOPT_FILE, $out);
           curl_setopt($ch, CURLOPT_URL, $posturl);
           curl_setopt($ch, CURLOPT_HEADER, false);
           curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
           curl_setopt($ch, CURLOPT_POST, 1);
           curl_setopt($ch, CURLOPT_POSTFIELDS, $params);         
           curl_setopt($ch, CURLOPT_VERBOSE, true);
           $streamVerboseHandle = fopen($CI->config->item('log_path').'curl_log.log', 'w ');
           cucurl_execrl_setopt($ch, CURLOPT_STDERR, $streamVerboseHandle);
           $output = curl_exec($ch);
           curl_close($ch);

$params looks like this:

(
    [json] => {"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[-73.32271671155468,44.55490573909421]},"properties":{"fldOriginalCode":"CR","fldOriginalValue":"Colchester Reef","fldDescription":"Estimated location of Colchester Reef"}}]}
)

I'm not sure why I can't get it to convert using a post request?

Thank you!

CodePudding user response:

It ended up working with this:

curl_setopt($ch, CURLOPT_POSTFIELDS, "json=$geojson");

instead of

curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 
  • Related