I'm using the "One-piece cover/spine width calculation API" described in the API documentation. I'm passing my API key on the URL as a GET parameter, as indicated in the docs, like so:
I'm getting a 200 response with the message "no data was posted" -- suggesting that my HTTP POST is reaching the server but there's no data attached to it. I'm not familiar with sending a GET parameter and POST data in the same HTTP request. Am I going about this in the expected way -- that is, by putting the api_key on the URL and then doing an HTTP POST to send the JSON data?
Most likely there is something amiss with the HTTP POST I'm sending -- which obviously is outside the scope of this forum -- but I can't see anything wrong with how I'm sending the POST request in the context of my programming language/platform, so I'm just throwing this out here in the hope that others have run into this and may have suggestions.
You are doing this the right way. My best guess as to the issue is that you are posting a Multi-part mime request. Some languages do this automatically when passed an array of data. Please make sure that your JSON request is not sent as a multi-part mime request.
Actually, the cover size calculation endpoint expects a single POST parameter called data, the value of which is the data structure you have provided. Try POSTing with a body of
I've tested my POST request further (by sending it to my own web server to see how the request is actually coming in), and it doesn't appear to be multi-part. The Content-Type header comes through as plain text:
I also tried sending it to Lulu as content-type application/json instead, but to no effect. I'm just not seeing anything wrong with the POST. Any other ideas?
Thanks, Josiah. I've added data= to make it a name/value pair. That appears to work, because now instead of getting "no data was posted" I'm getting "invalid JSON posted".
I'm not seeing anything wrong with the JSON syntax. Can you spot anything?
Same message for "coil". I realize that neither saddle-stitch nor coil have a spine, but shouldn't the API return a "coverSizeData" object with the spine info omitted or empty but containing the other cover size info? For a 50-page document, both saddle-stitch and coil should be legitimate binding types, right?
Unfortunately only books with spines (perfect, jacket-hardcover, casewrap-hardcover) are included in the size calculator. Other types of books should have a cover PDF with a height equal to that of the trim size, and a width twice the width of the trim size.
is that spineWidth and spineIndentation are required fields. For saddle-stitch, do I omit those fields, or include them but leave them blank, or include them but indicate zero?
Also, when indicating fullCoverDimension width as 2x trim size and height as 1x trim size as you said above, I know the value in inches (I'm doing US_TRADE, so 6" x 9") but not in points. Do I have to provide the dimensions in both inches and points?
I'm using the "One-piece cover/spine width calculation API" described in the API documentation. I'm passing my API key on the URL as a GET parameter, as indicated in the docs, like so:
https://apps.lulu.com/api/pdfgen/covers/v1/calculateSize/?api_key=XXX
and posting this JSON data:
{
"numberOfPages" : 16,
"color" : true,
"trimSize" : "US_TRADE",
"bindingType" : "saddle-stitch",
"paperType" : "regular"
}
I'm getting a 200 response with the message "no data was posted" -- suggesting that my HTTP POST is reaching the server but there's no data attached to it. I'm not familiar with sending a GET parameter and POST data in the same HTTP request. Am I going about this in the expected way -- that is, by putting the api_key on the URL and then doing an HTTP POST to send the JSON data?
Most likely there is something amiss with the HTTP POST I'm sending -- which obviously is outside the scope of this forum -- but I can't see anything wrong with how I'm sending the POST request in the context of my programming language/platform, so I'm just throwing this out here in the hope that others have run into this and may have suggestions.
Message edited by Princeton Theological Seminary Library 2 years ago
Ryan Bloom – 2 years ago
You are doing this the right way. My best guess as to the issue is that you are posting a Multi-part mime request. Some languages do this automatically when passed an array of data. Please make sure that your JSON request is not sent as a multi-part mime request.
Ryan
Josiah Gore – 2 years ago
Actually, the cover size calculation endpoint expects a single POST parameter called data, the value of which is the data structure you have provided. Try POSTing with a body of
data={
"numberOfPages" : 16,
"color" : true,
"trimSize" : "US_TRADE",
"bindingType" : "saddle-stitch",
"paperType" : "regular"
}
Princeton Theological Seminary Library – 2 years ago
I've tested my POST request further (by sending it to my own web server to see how the request is actually coming in), and it doesn't appear to be multi-part. The Content-Type header comes through as plain text:
text/plain; charset=UTF-8
and the body of the POST is this:
{
"numberOfPages" : 16,
"color" : true,
"trimSize" : "US_TRADE",
"bindingType" : "saddle-stitch",
"paperType" : "regular"
}
I also tried sending it to Lulu as content-type application/json instead, but to no effect. I'm just not seeing anything wrong with the POST. Any other ideas?
Princeton Theological Seminary Library – 2 years ago
Thanks, Josiah. I've added data= to make it a name/value pair. That appears to work, because now instead of getting "no data was posted" I'm getting "invalid JSON posted".
I'm not seeing anything wrong with the JSON syntax. Can you spot anything?
Princeton Theological Seminary Library – 2 years ago
I've noticed that if the binding type is "perfect", like so:
{"numberOfPages":50, "color":true, "trimSize":"US_TRADE", "bindingType":"perfect", "paperType":"regular"}
I get back the expected JSON response indicating the cover dimensions:
{"coverSizeData":{"spineWidth":{"valueInPoints":"9","valueInInches":"0.12"},"fullCoverDimension":{"width":{"valueInPoints":"891","valueInInches":"12.38"},"height":{"valueInPoints":"666","valueInInches":"9.25"}},"spineIndentation":{"length":{"valueInPoints":"441","valueInInches":"6.12"},"orientation":"FROM_LEFT"}},"status":200,"details":null}
But if the binding type is "saddle-stitch":
{"numberOfPages":50, "color":true, "trimSize":"US_TRADE", "bindingType":"saddle-stitch", "paperType":"regular"}
then I get this:
{"coverSizeData":null,"status":500,"details":"invalid JSON posted"}
Same message for "coil". I realize that neither saddle-stitch nor coil have a spine, but shouldn't the API return a "coverSizeData" object with the spine info omitted or empty but containing the other cover size info? For a 50-page document, both saddle-stitch and coil should be legitimate binding types, right?
Josiah Gore – 2 years ago
Unfortunately only books with spines (perfect, jacket-hardcover, casewrap-hardcover) are included in the size calculator. Other types of books should have a cover PDF with a height equal to that of the trim size, and a width twice the width of the trim size.
Princeton Theological Seminary Library – 2 years ago
OK, thanks -- although that should be documented.
Princeton Theological Seminary Library – 2 years ago
The indication here:
http://developer.lulu.com/docs/createpdf/PDF_Data_Structures#coverSizeData
is that spineWidth and spineIndentation are required fields. For saddle-stitch, do I omit those fields, or include them but leave them blank, or include them but indicate zero?
Also, when indicating fullCoverDimension width as 2x trim size and height as 1x trim size as you said above, I know the value in inches (I'm doing US_TRADE, so 6" x 9") but not in points. Do I have to provide the dimensions in both inches and points?