1

There is the following code:

params =
  method: 'DELETE'
  url: "profiles/#{@currentProfile.id}/boxes/#{@box.id}/messages"
  data:
    ids: ids
  headers:
    "Content-Type": "application/json;charset=utf-8" 
$http(params)

When I execute this DELETE request I see that this request has no body, i.e. my request has no "ids" param in the body. How can I fix it? I saw some answer on StackOverflow, where people gave advice to set 'Content-Type' header. I did it, but it didn't help me.

malcoauri
  • 11,904
  • 28
  • 82
  • 137

1 Answers1

2

I have tested your configuration (codepen). You can see in the dev tools that the request body is sent fine:

params =
  method: 'DELETE'
  url: "someurl"
  data:
    ids: [1,2,3]
    something: 'anything'
  headers:
    "Content-Type": "application/json;charset=utf-8" 
$http(params)

DELETE request body

Keep in mind that some backends will ignore the DELETE body by default. Try to redesign you API.

Have a look at:

Community
  • 1
  • 1
fracz
  • 20,536
  • 18
  • 103
  • 149