Hi,
I’m doing a POST to harvest.com to create a project. The project is created, but the Response is supposed to include the location of the new project in the field Location. The problem is, I can’t get that field, even though it appears to be one of the standard fields.
My code:
[php]
$credentials = “myemail:mypassword”;
$xml_data = ’
suprolapsteel
true
none
94687
none
’ ;
$url = “http://fullcity.harvestapp.com/projects”;
$headers = array(
“Content-type: application/xml”,
“Accept: application/xml”,
"Authorization: Basic " . base64_encode($credentials)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_USERAGENT, “Worksmart_Havest_Connector”);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
$response = curl_exec($ch);
if (curl_errno($ch)) {
print "Error: " . curl_error($ch);
} else {
// Show me the result
$info = curl_getinfo($ch);
var_dump($info);
curl_close($ch);
}
[/php]
I get an array that includes status 201 and a bunch of standard fields, but no Location field. Tech support confirmed that they get the Location when doing straight CURL.
Is there some other approach I can try? I should mention that I modified a sample script to do this. Unfortunately I’m very new to php and know even less curl.
Thanks,
-jb