Alright, making progress but something’s off. I must admit it might be my misunderstanding of the API documentation or the whole multipart request. But some error messages are encouraging 
In the off chance that this is linked to my formating of the body using Hugo, I’ll post here as a follow up…
This is how I construct my body:
{{ $body := printf
`--535e329ca936f79a19ac9a251f7d48f7\r\n
Content-Type: application/json\r\n
Content-Disposition: form-data; filename=article.json; name=article.json\r\n
%s\r\n
--535e329ca936f79a19ac9a251f7d48f7--
` $article_content }}
The $article_content
contains a jsonified object but the resulting error is:
{
"code":"MISSING",
"keyPath":["article.json"]
}
Which by reading the doc means the article file is missing.
Before adding the \r\n
to the boundaries I had a “INVALID_MIME_MULTIPART” code, so at least it means the body is not misformed… maybe the article is…
It might be that the printf
of the json string is somehow not valid. But printing it on a page, it looks good (no escaped quotes etc…)
I realize, this might require much more that than the limited information I’m pasting here for in order to properly help, but maybe someone will notice a low hanging fruit I’m missing…
Thanks!
As a reference here is what the APPLE NEWS doc propose as an example:
POST /channels/63a75491-2c4d-3530-af91-819be8c3ace0/articles HTTP/1.1
Host: news-api.apple.com
Accept: application/json
Content-Type: multipart/form-data; boundary=535e329ca936f79a19ac9a251f7d48f7
Content-Length: 94348
Authorization: HHMAC; key="1e3gfc5e-e9f8-4232-a6be-17bf40edad09"; signature="gJYsk8qm+6wpONE8twX/yDlGRt0UzS7Qn32yHNpiwnM="; date="2015-03-05T03:00:27Z"
--535e329ca936f79a19ac9a251f7d48f7
Content-Type: application/json
Content-Disposition: form-data; filename=article.json; name=article.json
{
"version": "1.7",
"identifier": "SampleArticle",
"language": "en",
"title": "Apple News App",
"subtitle": "A look at the features of the News iOS app",
"layout": {
"columns": 7,
"width": 1024,
"margin": 75,
"gutter": 20
},
"components": [
{
"role": "title",
"text": "Apple News App",
"textStyle": "title"
},
{
"role": "body",
"text": "The Apple News Format allows publishers to craft beautiful editorial layouts. Galleries, audio, video, and fun interactions like animation make stories spring to life."
},
{
"role": "photo",
"URL": "bundle://image.jpg"
}
],
"documentStyle": {
"backgroundColor": "#F7F7F7"
},
"componentTextStyles": {
"default": {
"fontName": "Helvetica",
"fontSize": 13,
"linkStyle": {
"textColor": "#428bca"
}
},
"title": {
"fontName": "Helvetica-Bold",
"fontSize": 30,
"hyphenation": false
},
"default-body": {
"fontName": "Helvetica",
"fontSize": 13
}
}
}
--535e329ca936f79a19ac9a251f7d48f7
Content-Type: image/jpeg
Content-Disposition: form-data; filename=mountain-lions.jpg; name=my_image
{binary content of mountain-lions.jpg}
--535e329ca936f79a19ac9a251f7d48f7
Content-Type: application/octet-stream
Content-Disposition: form-data; filename=gradient.png; name=a_gradient
{binary content of gradient.png}
--535e329ca936f79a19ac9a251f7d48f7--