Youtube API上传 - 发布400错误请求时出错

时间:2012-04-13 14:08:58

标签: .net api youtube httpwebrequest

我有一些.net代码产生以下帖子(原始数据从fiddler,二进制数据被截断)但是我每次发送请求时都收到400个错误请求

POST http://uploads.gdata.youtube.com/feeds/api/users/default/uploads HTTP/1.1
Authorization: OAuth ya29.AHES6ZTq4wOyYah1NRGrelvmg8icDsKwjkZuhN_IOdgDX75-
GData-Version: 2
X-GData-Key: key=..apikey...
Slug: sample.AVI
Content-Type: multipart/related; boundary="dsjdwdjd3"
Host: uploads.gdata.youtube.com
Content-Length: 1980444
Expect: 100-continue
Connection: Close

--dsjdwdjd3
Content-Type: application/atom+xml; charset=UTF-8
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007">
  <media:group>
    <media:title type="plain">testVideo1</media:title>
    <media:description type="plain">this is a test video1</media:description>
    <media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People</media:category>
    <media:keywords>test1</media:keywords>
  </media:group>
</entry>
--dsjdwdjd3
Content-Type: video/avi
Content-Transfer-Encoding: binary

RIFF�4�AVI LIST&....... truncated binary....
--dsjdwdjd3

这里是关于POST的google文档,但据我所知,它看起来很像https://developers.google.com/youtube/2.0/developers_guide_protocol_direct_uploading

我的代码背后是将其发送为httpwebrequest,这就是我所拥有的。

编辑:我不认为这是一个身份验证或开发人员密钥问题,因为我故意输入了错误的详细信息,并且它返回了401无效令牌或无效的开发人员密钥。

编辑2:完整回复,以fiddler的原始格式粘贴

HTTP/1.1 400 Bad Request
Server: HTTP Upload Server Built on Apr 10 2012 14:42:33 (1334094153)
Content-Type: text/html; charset=UTF-8
X-GUploader-UploadID: AEnB2Up2iQ676IS9KRGmvmdbgBFGZLwLXHmnSv3cTUu-1TAHbuylsLncHOK0Q0MBSg22ZaGQ8aQ3JQps5bmAJ9xaYtYq1jNI_Q
Date: Mon, 16 Apr 2012 10:11:10 GMT
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control: no-cache, no-store, must-revalidate
Content-Length: 15
Connection: close

Invalid Request

0 个答案:

没有答案