HTTP Post请求遇到错误?

编程入门 行业动态 更新时间:2024-10-21 11:54:48
本文介绍了HTTP Post请求遇到错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试创建一个用于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请求遇到错误?

本文发布于:2023-10-11 23:13:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483107.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   HTTP   Post

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!