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.

4
  • Depending on your backend - a body in the delete request might be being ignored. Commented Nov 18, 2015 at 17:02
  • @tymeJV - no, I look at Firebug/Chrome Dev Tools Commented Nov 18, 2015 at 17:30
  • "my request has no 'ids' param" - What do you mean by param? You send JSON not parameters. Commented Nov 18, 2015 at 17:40
  • @zeroflagL I mean request body ("data" key of my "params" var) Commented Nov 18, 2015 at 17:49

1 Answer 1

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:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.