1

I have a REST API as below which is using the HTTP DELETE method. I have to pass this body in that HTTP DELETE method in Angular. Please help. I cannot change the structure of this body

{
  "transactions": [
    {
      "eventId": "21012200237172",
      "productCode": "LC",
      "id": "LC20110000090023"
    }
  ]
}
Gaurav Jeswani
  • 4,410
  • 6
  • 26
  • 47
learnerNT
  • 9
  • 4

1 Answers1

1

you can pass body in httpdelete with options

let apiUrl = 'yourUrl';
let transactions = [{
    "eventId": "21012200237172",
    "productCode": "LC",
    "id": "LC20110000090023"
}];

const options = {
  headers: new HttpHeaders({
    'Content-Type': 'application/json',
  }),
  body: {
    transactions: transactions
  },
};

this.httpClient
  .delete(apiUrl, options)
  .subscribe((s) => {
    console.log(s);
  },err => {
    console.log(err);
  });