我想使用nestful gem向我的Sinatra应用程序的控制器中的外部API端点发送DELETE请求。我想通过向TeamSnap API的端点发送DELETE请求来删除事件。我在控制器中定义了以下路由:
var sorgu = from görevler in db.tbl_TaskOfProjects
join projeler in db.tbl_Projects
on görevler.project_id equals projeler.project_id
select new
{
görevler.p_task_id,
görevler.p_task_name,
görevler.p_task_start_date,
görevler.p_task_end_date,
görevler.p_task_status,
görevler.p_task_detail,
görevler.p_task_corporation,
projeler.project_id,
projeler.project_name
};
gridGörevler.DataSource = sorgu;
当API端点被delete '/events/:id' do
delete 'https://api.teamsnap.com/v3/events/76674685'
end
操作命中时,我收到以下错误:
delete
如果我向API端点发送get请求,我会得到正确的响应。我正在使用的获取请求如下:
*** "Delete" argument "endpoint" needs to be a number
任何人都可以确认我们如何在控制器中发送DELETE请求以及我缺少什么?
提前致谢!
答案 0 :(得分:0)
[已解决]:我使用以下命令通过Nestful发送了DELETE请求:
delete '/events/:id' do
request = Nestful::Request.new(endpoint, options)
request.method = 'delete'
response = request.execute
end
在上面的代码中,endpoint
为“https://api.teamsnap.com/v3/events/EVENT_ID”,options
是包含“内容类型”和“授权”标题的哈希。