我正在尝试创建一个用于OneDrive文件访问的新共享链接.
I am trying create a new share link for onedrive file access.
这是我应该做的,
POST /drive/items/{item-id}/action.createLink Content-Type: application/json { "type": "view" }我已经在ruby中创建了一个发帖请求,如下所示,
I have created a post request in ruby as follow,
require 'net/http' require 'json' uri = URI.parse("api.onedrive/v1.0") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true req = Net::HTTP::Post.new("api.onedrive/v1.0/drive/items/file.88e469b2d4c51142.88E469B2D4C51142!113/action.createLink") req.content_type = "application/json" json = {:type=> "view"}.to_json req.body = json response = http.request(req) puts response.body puts response通过运行上面的代码,我得到以下错误为JSON,
By running the above code I am getting the following error as JSON,
{ "error": { "code": "invalidArgument", "message": "ObjectHandle is Invalid", "innererror": { "code": "badArgument", "innererror": { "code": "invalidObjectHandle", "innererror": { "code": "invalidResourceId" } } } } }给我的第一印象是我为request.body设置了错误的JSON值,如何克服这个错误?
My first impression is that I am setting the request.body with a wrong value of JSON how to overcome this error?
推荐答案您提供的ID(file.88e469b2d4c51142.88E469B2D4C51142!113)不是此API的有效ID.它看起来像是从LiveConnect API获得的,但与该新API不兼容.如果您使用新的api获取ID并将其与您的同一查询一起使用,那么它应该可以正常工作.
The id you provided (file.88e469b2d4c51142.88E469B2D4C51142!113) is not a valid id for this API. It looks suspiciously like one obtained from the LiveConnect API, and those aren't compatible with this new API. If you obtain the id using the new api and use that with your same query it should work.
更多推荐
HTTP Post请求遇到错误?
发布评论