标签: http-delete

当方法类型为DELETE时,如何使用Ext.Ajax.request传递参数

我试图发送使用Ext.Ajax.request方法删除服务器上的一些数据.我的请求方法如下所示:

Ext.Ajax.request({
      url: '/myserver/restful/service/delete',
      method: 'DELETE',
      headers: {
        'Content-Type': 'application/json'
      },
      params: {
        userId: 12345
      }
});
Run Code Online (Sandbox Code Playgroud)

在我的球衣服务器上,我写了如下所示:

@Path("/delete")
  @DELETE
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public Response deleteUser(final String userId) {
    System.out.println("user id = " + userId);
    return Response.ok().entity("success").build();
  }
Run Code Online (Sandbox Code Playgroud)

此方法以下列格式打印出用户ID:

user id = userId=12345

所以我的预期价值userId是,12345但它给了我userId=12345.因为我是球衣的新手,我现在无法决定做什么.

任何人都可以告诉你出了什么问题?

rest http jersey http-delete extjs4.1

3
推荐指数
1
解决办法
3631
查看次数

使用Guzzle删除带参数的请求

我必须在CodeIgnitor平台中使用参数执行DELETE请求.首先,我尝试使用cURL,但我切换到了Guzzle.

控制台中的请求示例如下:

curl -X DELETE -d '{"username":"test"}' http://example.net/resource/id
Run Code Online (Sandbox Code Playgroud)

但是在Guzzle的文档中,他们像GET一样使用参数DELETE http://example.net/resource/id?username=test,我不想这样做.

我尝试过:

$client = new GuzzleHttp\Client();
$client->request('DELETE', $url, $data);
Run Code Online (Sandbox Code Playgroud)

但请求只是调用DELETE http://example.com/resource/id没有任何参数.

php curl codeigniter http-delete guzzle

3
推荐指数
1
解决办法
6713
查看次数

ASP.NET Web API 删除返回 404

在本地 IIS 7.5 上使用 ASP.NET (4.6.1) Web Api 我试图调用一个删除方法:

[HttpDelete]
[Route("Values/")]
public IHttpActionResult DeleteValue(int id)
{         
    return Ok();
}
Run Code Online (Sandbox Code Playgroud)

以下 DELETE 请求工作得很好:

https://localhost/api/Values?id=22

但是,我想像这样调用 DELETE 请求:

https://localhost/api/Values/22

这给了我: 404.0 — Not Found

我的 api 路由配置定义如下:

config.Routes.MapHttpRoute(
    name: "DefaultApi",
    routeTemplate: "api/{controller}/{id}",
    defaults: new { id = RouteParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)

我的 web.config 看起来像:

 <system.webServer>
<handlers>
  <remove name="WebDAV" />
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <remove name="TRACEVerbHandler" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<modules>
  <remove name="WebDAVModule" />
</modules>
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

c# asp.net iis-7.5 http-delete asp.net-web-api

3
推荐指数
1
解决办法
2995
查看次数

将多个参数传递给 DELETE 请求 c# web API

我的问题是如何将多个参数传递给 DELETE 请求。

我的控制器类如下,

namespace MYAPI1.Controllers
{
    public class TaskController : ApiController
    {
        // DELETE: api/Task/5
        [Route("api/Task/id1/id2/{id3}")]
        public void Delete(int id,int id2, string id3)
        {
            TaskPersistent tp = new TaskPersistent();
            tp.deleteTask(id,id2,id3);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

TaskPersistent.class 如下,

public class TaskPersistent
{
    public void deleteTask(int id, int id2, string id3)
    {

        try
        {
            string sqlString = "DELETE from devproj WHERE (DeveloperID, ProjectID, WorkDate) =  VALUES ('" + id + "', '" + id2 + "', '" + id3 + "');";
            MySql.Data.MySqlClient.MySqlCommand cmd …
Run Code Online (Sandbox Code Playgroud)

c# parameters rest http-delete asp.net-web-api2

3
推荐指数
1
解决办法
1万
查看次数

删除记录后角度刷新表,使用材质表和rest api

我有一个带有可扩展行的材质表(https://material.angular.io/components/table/examples),并且我想管理表本身的删除,因此我创建了一个带有触发删除事件的函数的删除按钮。api有效,记录被正确删除,但删除后表没有刷新,我想实现这种行为。这里有一个带有假 API 的 stackblitz:https ://stackblitz.com/edit/angular-comzph

我尝试在删除函数中调用 ngOnInt 并导航回同一路线,但没有任何反应......

deleteCustomer(id) {
 this.api.deleteCustomer(id)
  .subscribe(res => {
    alert(`cliente rimosso`);
    // TODO fix reload list after delete
    // this.router.navigate['/clienti'];
    this.ngOnInit();
  }, (err) => {
    console.log(err);
  }
 );
}
Run Code Online (Sandbox Code Playgroud)

我也尝试使用这个解决方案,但不起作用。我尝试使用 ngOnChange 和 ngOnDestroy,但也不起作用......

有人可以帮助我吗?

rest refresh http-delete angular-material angular

3
推荐指数
1
解决办法
2万
查看次数

为什么我在"删除"请求中收到"无路由匹配[GET]"?Ruby on Rails

当我尝试删除communityfeed_item/micropost的内容时,我收到以下错误:

Routing Error

No route matches [GET] "/microposts/45"
Try running rake routes for more information on available routes.
Run Code Online (Sandbox Code Playgroud)

我检查我的路线并看到删除和发布,这是我真正需要的功能,但我一直收到"获取"错误.

posts GET    /posts(.:format)               posts#index
               POST   /posts(.:format)               posts#create
      new_post GET    /posts/new(.:format)           posts#new
     edit_post GET    /posts/:id/edit(.:format)      posts#edit
          post GET    /posts/:id(.:format)           posts#show
               PUT    /posts/:id(.:format)           posts#update
               DELETE /posts/:id(.:format)           posts#destroy
     locations GET    /locations(.:format)           locations#index
               POST   /locations(.:format)           locations#create
  new_location GET    /locations/new(.:format)       locations#new
 edit_location GET    /locations/:id/edit(.:format)  locations#edit
      location GET    /locations/:id(.:format)       locations#show
               PUT    /locations/:id(.:format)       locations#update
               DELETE /locations/:id(.:format)       locations#destroy
    communitys GET    /communitys(.:format)          communitys#index
               POST   /communitys(.:format)          communitys#create
 new_community GET    /communitys/new(.:format)      communitys#new …
Run Code Online (Sandbox Code Playgroud)

routes get ruby-on-rails http-delete

2
推荐指数
1
解决办法
2390
查看次数

在HttpURLConnection中发送PUT,DELETE HTTP请求

我使用java下面的代码创建了Web服务调用.现在我需要进行删除和执行操作.

URL url = new URL("http://example.com/questions");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod( "POST" );
conn.setRequestProperty("Content-Type", "application/json");

OutputStream os = conn.getOutputStream();
os.write(jsonBody.getBytes());
os.flush();
Run Code Online (Sandbox Code Playgroud)

当我添加以下代码来执行DELETE操作时,它会给出错误说:

java.net.ProtocolException:HTTP方法DELETE不支持输出.

conn.setRequestMethod( "DELETE" );
Run Code Online (Sandbox Code Playgroud)

那么如何执行删除和放置请求?

java web-services http-post httpurlconnection http-delete

2
推荐指数
1
解决办法
1万
查看次数

WEB API 2 Delete返回405

我正在尝试在我的Web API类中创建一个删除功能.我之前使用Put和Patch Http消息时遇到了问题,因为这些消息被链接到WebDAV.更改此功能后,Patch和Put工作正常,但删除功能会给我带来问题.

这是我的班级:

[RoutePrefix("api/Account")]
public class AccountController : ApiController
{
     //private AuthRepository _repo = null;
    Orchestrate.Net.Orchestrate orchestrate = new Orchestrate.Net.Orchestrate("0b42c04c-0d70-4da8-a3c1-2036882369d0");

[..rest of class here..]

// DELETE: api/account/5
[AllowAnonymous]
[HttpDelete]
public void Delete(string username)
{
   orchestrate.Delete("users", username, true);
}

}
Run Code Online (Sandbox Code Playgroud)

我试过了:

  • 使用IHttpActionResult,使用int作为标识符删除方法的几个不同变体
  • 更改web.config
  • 在Delete方法本身上添加路由定义

浏览网页时,我发现许多人的Web.Config文件都有问题,但我的网络似乎很好.这是每个人都在谈论的部分.

  <system.webServer>
    <modules>   <remove name="WebDAVModule"/> </modules>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <remove name="WebDAV" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>   
   </system.webServer>
Run Code Online (Sandbox Code Playgroud)

这是我的要求:

DELETE http://localhost:41021/api/account/JoopSloop HTTP/1.1
Host: localhost:41021
Connection: keep-alive …
Run Code Online (Sandbox Code Playgroud)

asp.net http http-delete asp.net-web-api2

2
推荐指数
1
解决办法
5155
查看次数

Rest Api:何时使用 Post、PUT、PATCH 和 Delete

我正在开发一个宁静的 api,我需要更新一个资源(即一个包含 10 个字段的客户详细信息记录)。

在添加请求时,我发送一个带有完整记录的 Post 请求。在更新请求时,我发送一个包含 10 个字段的完整记录的 PUT 请求。在验证请求中,我发送一个只有两个字段的 PUT 请求,即 recordId 和 versionNo。在删除请求时,我在 HttpOptions 中发送一个带有两个字段的 DELETE 请求。

我有几个问题:

  • 虽然,它是一个宁静的 api,但它是一个特定的应用程序,它将被一个有角度的应用程序使用,所以我应该返回数据以响应 POST/PUT 请求。

  • 我应该在验证的情况下使用 PATCH(或任何其他仅将 recordId 和 versionNo 发送到服务器以更改某些字段的操作)还是可以使用 PUT。

  • 为了统一起见,我是否应该在删除请求的正文中发送数据,因为我需要 recordId 和 versionNo 来删除记录。

rest http-post http-put http-method http-delete

2
推荐指数
1
解决办法
8862
查看次数

HTTP DELETE 方法幂等性

只是一个关于 REST Web 服务HTTP DELETE方法的基本问题。根据 HTTP 协议文档,DELETE是幂等的。但是我们第一次发送时,您会收到 200 响应代码,随后的请求会收到 404 错误,因为该资源不存在。那么,如果响应不同,为什么它会被称为幂等呢?

rest service http http-delete web

1
推荐指数
1
解决办法
464
查看次数