【问题标题】:Vimeo API - unacceptable content-type: text/plainVimeo API - 不可接受的内容类型:文本/纯文本
【发布时间】:2015-02-12 16:05:42
【问题描述】:

我在我的 iOS 应用程序中使用 Vimeo API。但是由于几天它已经停止工作,当我尝试上传任何视频时它给了我错误。

以下是方式,我正在创建请求

    NSURL *uploadURL = [NSURL URLWithString:endpoint];
        OAMutableURLRequest *req = [[OAMutableURLRequest alloc] initWithURL:uploadURL consumer:self._oaconsumer token:self._authToken realm:nil signatureProvider:self._sigProv];
        [req setTimeoutInterval:60.0];
        [req setHTTPMethod:@"PUT"];
        [req setValue:[NSString stringWithFormat:@"%ld",(unsigned long)self._byteSizeOfVideo] forHTTPHeaderField:@"Content-Length"];
        [req setValue:@"video/quicktime" forHTTPHeaderField:@"Content-Type"];

我收到以下错误消息,

Printing description of error:
Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)" UserInfo=0x1705bc80 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x15d1ff60> { URL: http://1511655313.cloud.vimeo.com/upload_multi?ticket_id=75225c91f65b14315902b8bee5fbbc44&amp;signature=6126962b362c9c0777bce88556211572 } { status code: 400, headers {
    "Access-Control-Allow-Origin" = "*";
    Connection = close;
    "Content-Length" = 28;
    "Content-Type" = "text/plain";
    Date = "Thu, 12 Feb 2015 15:46:12 GMT";
    Server = "Vimeo/1.0";
} }, NSErrorFailingURLKey=http://1511655313.cloud.vimeo.com/upload_multi?ticket_id=75225c91f65b14315902b8bee5fbbc44&amp;signature=6126962b362c9c0777bce88556211572, NSLocalizedDescription=Request failed: bad request (400), com.alamofire.serialization.response.error.data=<5369676e 61747572 65205661 6c696461 74696f6e 20666169 6c65640a>, NSUnderlyingError=0x15d237a0 "Request failed: unacceptable content-type: text/plain"}

请提供必要的帮助。

谢谢!

【问题讨论】:

  • 向我们展示您用于创建 AlamoFire 请求的代码。看起来您正在设置正文 JSON 而不是 HTTP 标头值
  • @WarrenBurton .. 请现在检查我的请求,我已经编辑了我的帖子。实际上我已经提到了我的参数的日志,因此它以 JSON 格式显示。谢谢!
  • 考虑使用新开源的Vimeo iOS Upload SDK。它使用(后台)NSURLSession 处理将视频文件上传到 Vimeo 服务器。 (我是作者之一。)
  • @AlfieHanssen 是的,适用于 iOS 的新 Vimeo SDK 很棒。
  • 太棒了,很高兴听到这个消息,请随时在 repo/make PRs 上提出问题。

标签: ios afnetworking vimeo-api http-status-code-400 vimeo-ios


【解决方案1】:

终于找到bug了,

在获取票证 ID 时,我收到以下响应

<?xml version="1.0" encoding="UTF-8"?>
<rsp generated_in="0.0308" stat="ok">
  <ticket endpoint="http://1511635510.cloud.vimeo.com/upload_multi?ticket_id=090b9f68cce28467537cc6cc2d921c4d&amp;signature=a9362ca1ec4bc8e624ef1e5d274ccb6e" endpoint_secure="https://1511635510.cloud.vimeo.com/upload_multi?ticket_id=090b9f68cce28467537cc6cc2d921c4d&amp;signature=a9362ca1ec4bc8e624ef1e5d274ccb6e" host="1511635510.cloud.vimeo.com" id="090b9f68cce28467537cc6cc2d921c4d" max_file_size="5363328222"/>
</rsp>

现在我在这里使用enpoint url 上传视频,但在我找到的端点 url &amp;amp; 代替了&amp;,这浪费了我很多时间。

【讨论】:

    猜你喜欢
    • 2014-01-15
    • 2016-07-13
    • 2016-09-27
    • 2018-05-11
    • 1970-01-01
    • 2014-06-14
    • 1970-01-01
    • 2016-06-02
    • 2012-02-15
    相关资源
    最近更新 更多