1

我已经设置了 Geode rest API,并且可以通过 Chrome 在一个区域上运行获取和查询,例如:

http://localhost:8080/gemfire-api/v1/items

当我尝试使用以下端点根据开发 REST 应用程序删除区域中的条目时:

DELETE /gemfire-api/v1/{region}

例如:

http://localhost:7070/gemfire-api/v1/items

您能告诉我如何在 Chrome 中运行该示例并删除条目吗?我只是想能够跑

http://localhost:8080/gemfire-api/v1/items/delete

但相反,我得到

{"cause":"Key (delete) does not exist for region (items) in cache!"}

4

2 回答 2

1

您将需要使用 ajax。这DELETE是在谈论您需要的 HTTP 动词,而不是您需要将其添加到 URL 中。

让您的删除功能执行此代码:

$.ajax({
    url: 'http://localhost:7070/gemfire-api/v1/items,
    type: 'DELETE',
    data: {item:item}, //<-----this should have to be an object of your item type.
    contentType:'application/json', 
    dataType: 'text',                
    success: function(result) {...}, // <---update this with a callback
    error: function(result){...}// <---update this with a callback
});
于 2017-08-07T13:50:33.293 回答
1

通过浏览器 Chrome,您可以使用Postman之类的扩展程序

它将允许您使用任何动词发送请求,因此您可以简单地测试请求,然后再在您所做的任何事情中使用它们,例如您的网站)

GET(就像你在浏览器中输入 url 并点击Enter

POST(就像您提交表单时一样)

删除(你想要的那个)

PUT(另一个广泛用于更新现有对象的动词)

使用说明: 在此处输入图像描述

于 2017-08-07T14:49:24.877 回答