I am trying create a new share link for onedrive file access.
This is what I am supposed to do,
POST /drive/items/{item-id}/action.createLink
Content-Type: application/json
{
"type": "view"
}
I have created a post request in ruby as follow,
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
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"
}
}
}
}
}
My first impression is that I am setting the request.body with a wrong value of JSON how to overcome this error?