I am struggling a bit to get a project to update. I'm using PHP with the following (after authenticating correctly):
$url = "https://apps.lulu.com/api/publish/v1/update/id/".$content_id;
$data = array('publisher' => $metadata, 'api_key' => $apikey, 'auth_token' => $authToken, 'auth_user' =>$authUser);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
die;
$metadata is the unaltered json string with the project info obtained using the lulu api.
However I get the response :
{"error_value": "project", "error_type": "KeyError", "additional": "?"}
You likely simply need to change 'publisher' key to 'project' in the dictionary you are POSTing. The API is looking for 'project' for the data with which to update, which is why you are seeing a KeyError when it is not found.
Could you post a dump of the $metadata structure? It's hard to know where the problem is parsing the structure without seeing how the data is being supplied.
Try removing the outer dictionary, using 'project' only as the key in the POST data key value pairs rather than as a key in the JSON dictionary. So, instead of passing
...seems to be the answer. Now I went through a other 'missing field' errors but stuck on:
{"error_value": "Missing or invalid delivery id", "error_type": "LInvalidProductException"}
hi,
I am struggling a bit to get a project to update. I'm using PHP with the following (after authenticating correctly): $url = "https://apps.lulu.com/api/publish/v1/update/id/".$content_id; $data = array('publisher' => $metadata, 'api_key' => $apikey, 'auth_token' => $authToken, 'auth_user' =>$authUser); $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); curl_close($ch); print_r($response); die;
$metadata is the unaltered json string with the project info obtained using the lulu api.
However I get the response : {"error_value": "project", "error_type": "KeyError", "additional": "?"}
Any idea what I am doing wrong?
adam
{"error_value": "project", "error_type": "KeyError", "additional": "?"}
Message edited by eset 2 years ago
eset – 2 years ago
sorry, here is a better formatted code block
Josiah Gore – 2 years ago
You likely simply need to change 'publisher' key to 'project' in the dictionary you are POSTing. The API is looking for 'project' for the data with which to update, which is why you are seeing a KeyError when it is not found.
eset – 2 years ago
ah..thanks. i did that now and it still returns the same error.
eset – 2 years ago
actually the error i get now is:
{"error_value": "content_id", "error_type": "KeyError", "additional": "?"}
the code I am using is :
Josiah Gore – 2 years ago
Could you post a dump of the $metadata structure? It's hard to know where the problem is parsing the structure without seeing how the data is being supplied.
eset – 2 years ago
sure, this is the raw data what goes into $metadata:
{"project": {"bibliography": {"category": 0, "publisher": "", "copyright_citation": "", "description": "", "license": "Standard Copyright License", "title": "newscoop tester", "language": "EN", "copyright_year": 2011, "edition": "", "country_code": "US", "authors": [{"first_name": "adam", "last_name": "hyde"}], "keywords": []}, "program_code": null, "access": "private", "drm": false, "allow_ratings": true, "project_type": "softcover", "distribution": ["lulu_marketplace"], "content_id": 10563289, "physical_attributes": {"color": false, "trim_size": "US_TRADE", "binding_type": "perfect", "paper_type": "regular"}, "pricing": [{"total_price": 0.79000000000000004, "product": "download", "royalty": 0, "currency_code": "EUR", "discount_percent": 0}, {"total_price": 9.1400000000000006, "product": "print", "royalty": 0, "currency_code": "EUR", "discount_percent": 0}]}}
Josiah Gore – 2 years ago
Try removing the outer dictionary, using 'project' only as the key in the POST data key value pairs rather than as a key in the JSON dictionary. So, instead of passing
simply pass in
eset – 2 years ago
thanks!
...seems to be the answer. Now I went through a other 'missing field' errors but stuck on: {"error_value": "Missing or invalid delivery id", "error_type": "LInvalidProductException"}
any idea what that is?
:)
adam
eset – 2 years ago
actually, i found the error...something to do with incorrect info in the product download pairs...thanks a lot for your help :)
Josiah Gore – 2 years ago
I'm glad you were able to figure it out. Let me know if you have any more questions.