我试图创建一个新的共享链接onedrive文件访问。
这是我应该做的,
POST /drive/items/{item-id}/action.createLink
Content-Type: application/json
{
"type": "view"
}
我在红宝石中创建一个POST请求如下,
require 'net/http'
require 'json'
uri = URI.parse("https://api.onedrive.com/v1.0")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new("https://api.onedrive.com/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,
{
"error": {
"code": "invalidArgument",
"message": "ObjectHandle is Invalid",
"innererror": {
"code": "badArgument",
"innererror": {
"code": "invalidObjectHandle",
"innererror": {
"code": "invalidResourceId"
}
}
}
}
}
我的第一印象是,我设置request.body使用JSON的错误值,如何克服这个问题?