框->查看API->无法为document_id创建会话 [英] Box -> View API -> Can not create session for an document_id

查看:89
本文介绍了框->查看API->无法为document_id创建会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照Box.com View API的说明创建会话

To follow the instruction of Box.com View API on how to create a session

curl https://view-api.box.com/1/sessions \
-H "Authorization: Token YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"document_id": "ABC123"}' \
-X POST

我使用RestSharp编写代码:

I use RestSharp to write code:

var client = new RestClient("https://view-api.box.com/1/sessions");
            RestRequest request = new RestRequest(Method.POST);
            request.RequestFormat = DataFormat.Json;
            request.AddHeader("Authorization", "Token r6bcsuizpt18hwf9fsq7l15oj7fts12x");
            request.AddHeader("Content-type", "application/json");

            request.AddBody(new { document_id = "19877746783" });
            var response = client.Execute<HttpResponseMessage>(request).Content;

但是我得到了答复:

{"message": "Bad request", "type": "error", "details": [{"field": "document_id", "message": "Ensure this value has at least 32 characters (it has 11)."}], "request_id": "1e5ea09a373546c283d676d5c890cecb"}

而document_id 19877746783完全正确.

while document_id 19877746783 is exactly right.

我不知道为什么收到此消息. 谢谢

I don't know why I got this message. Thank you

推荐答案

该ID看起来好像不是由View API生成的(它们是32个字符).唯一适用于View API的ID来自使用 POST/documents 方法,即您将进行此API调用

The ID does not look like it was generated by the View API (they're 32 characters). The only IDs that will work with the View API are from documents that been uploaded directly to the View API using the POST /documents method first i.e. you'll make this API call

curl https://view-api.box.com/1/documents \
-H "Authorization: Token YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "URL_TO_DOCUMENT"}' \
-X POST

,并将收到此回复

{
    "type": "document",
    "id": "DOCUMENT_ID",
    "status": "done",
    "name": "",
    "created_at": "2013-08-30T00:17:37Z"
}

您需要使用DOCUMENT_ID以上述方法创建会话.

You'll need to use DOCUMENT_ID to create the session in the method you have above.

这篇关于框-&gt;查看API-&gt;无法为document_id创建会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆