404 on media-assets

12 views
Skip to first unread message

Tim Armes

unread,
Oct 3, 2011, 8:08:00 AM10/3/11
to TypePad Developers Network
Hi,

I'm trying to upload an image by POSTing a multipart message to /blogs/
<id>/media-assets.json, however on each attempt I get 404 returned.

Here's the URL:

https://api.typepad.com/blogs/6a014e8be6c69a970d015435c66efd970c/media-assets.json

Note that if I send a GET request to
https://api.typepad.com/blogs/6a014e8be6c69a970d015435c66efd970c.json
then a get a valid response back, so I know that there's no problem
with my ID.

I don't think that there's any problem with the payload - I'd expect
something other than 404 in that case.

Any ideas?

Tim

Martin Atkins

unread,
Oct 3, 2011, 1:03:13 PM10/3/11
to typepad-d...@googlegroups.com

Hi Tim,

I took a look at our API request logs to see if I could get some more
details about what failed in your request. However, for some reason I
don't see any requests for the URL you gave above.

Could you possibly share a bit of the code you're using to make this
request? I wonder if our API request dispatching code is dispatching
your request incorrectly for some reason.

Thanks,
Martin

Tim Armes

unread,
Oct 3, 2011, 2:36:25 PM10/3/11
to TypePad Developers Network

Hi Martin,

Thanks for looking into this. I'm really struggling now.

I've tried using WireShark to get some clues, but there's nothing
forthcoming - especially with everything encrypted. The source is in
lua and uses the SDK of the parent SDK environment, so it's probably
not going to help much. I've list it at the end but if you don't know
lua it might be a little confusing.

The debug output that you see the code generating looks like this:

Preparing content
Metadata: {"description" : "-1.jpg", "title" : "-1.jpg"}
Sending to https://api.typepad.com/blogs/6a014e8be6c69a970d015435c66efd970c/media-assets.json

I've just tried again a couple of times, perhaps it in the logs now?

Tim

DBGRAW("Preparing content")

local metadata = LRLib_JSON.serialise({
description = meta_summary,
title = meta_title
})

local uploadBody = table.concat({
"Media multipart posting",
"--PART_DELIMITER",
"Content-Type: application/json",
"",
metadata,
"--PART_DELIMITER",
"Content-Type: image/jpeg",
"",
image_data,
"--PART_DELIMITER--",
""
}, "\r\n")

local uploadURL = "https://api.typepad.com/blogs/" ..
pt.typepadBlog .. "/media-assets.json"

DBGRAW("Metadata: " .. metadata)
DBGRAW("Sending to " .. uploadURL)

-- Send the PUT/POST

local requestHeaders =
oauth:getAuthenticatedRequestHeaders(uploadURL, "POST",
pt.typepadCredentials, nil)
table.insert(requestHeaders, { field = 'Content-Type', value =
'Multipart/Related; boundary="PART_DELIMITER"' })
table.insert(requestHeaders, { field = 'MIME-version', value =
'1.0' })

local success, result, headers =
LrFunctionContext.pcallWithContext('Uploading',
function()
local r, h = LrHttp.post(uploadURL, uploadBody,
requestHeaders, "POST", 60)
return r, h
end)

Martin Atkins

unread,
Oct 3, 2011, 2:48:21 PM10/3/11
to typepad-d...@googlegroups.com
On 10/03/2011 11:36 AM, Tim Armes wrote:
>
> Hi Martin,
>
> Thanks for looking into this. I'm really struggling now.
>
> I've tried using WireShark to get some clues, but there's nothing
> forthcoming - especially with everything encrypted. The source is in
> lua and uses the SDK of the parent SDK environment, so it's probably
> not going to help much. I've list it at the end but if you don't know
> lua it might be a little confusing.
>

Although the API won't let you succeed with the POST over HTTP (since
auth is required for this request) you could try sending the request to
the non-SSL version of this endpoint just to capture what your client is
sending with Wireshark.

> table.insert(requestHeaders, { field = 'Content-Type', value =
> 'Multipart/Related; boundary="PART_DELIMITER"' })

One thing that stuck out to me is that you wrote multipart/related with
capital letters, but from reading our implementation it looks like we're
erroneously handling only lowercase. I don't know why this would result
in a 404 Not Found response, but maybe you could try it with the type
all in lowercase and see if that allows you to make progress.

If that fixes it, please let me know and I'll file a bug ticket to fix
our request handling to treat MIME types as case-insensitive.


Tim Armes

unread,
Oct 3, 2011, 3:08:59 PM10/3/11
to TypePad Developers Network
Hi,

I've tried sending to http, and I can see my message being sent with
WireShark. WireShark can successfully display the multipart data, so
that seems fine.

The server still responds with 404:

The requested URL /blogs/6a014e8be6c69a970d015435c66efd970c/media-
assets.json was not found on this server.<P>\n

Changing to lower case didn't fix it either.

Regards,

Tim

Martin Atkins

unread,
Oct 3, 2011, 9:08:38 PM10/3/11
to typepad-d...@googlegroups.com
On 10/03/2011 12:08 PM, Tim Armes wrote:
> Hi,
>
> I've tried sending to http, and I can see my message being sent with
> WireShark. WireShark can successfully display the multipart data, so
> that seems fine.
>
> The server still responds with 404:
>
> The requested URL /blogs/6a014e8be6c69a970d015435c66efd970c/media-
> assets.json was not found on this server.<P>\n
>
> Changing to lower case didn't fix it either.
>

Hi Tim,

I'm sorry that didn't work out.

I just noticed that this error message doesn't look like one the API
would normally generate. This, combined with the fact that your requests
don't seem to be showing up in the API logs, makes me think that for
some reason your requests are getting routed inside our infrastructure
somewhere other than the API service.

Would you mind sending the raw dump generated from wireshark so I can
see exactly what was sent on the wire? If you'd prefer not to post this
on the public mailing list feel free to email me directly.

Reply all
Reply to author
Forward
0 new messages