Convert JSON to multipart/form-data angular/ionic

When i send POST request form POSTMAN and get correct response

This is Form-Data Body request of Postman POST.


Success Respond when i request with Form-Data

When i send POST request from POSTMAN and get Wrong response

JSON Body request

Content-Type : multipart/form-data;

When i send POST request from POSTMAN and get Wrong response

Content-Type : multipart/form-data; header with json body :

Angular and IONIC code when i send post request

    const formData = new FormData();
    let httpOptions = {
        headers: new HttpHeaders({
            'Content-Type': 'multipart/form-data; charset=UTF-8'
    // rest data to the form.
    //Object.keys(restObj).forEach(key => {
    //  formData.append(key, restObj[key]);
    // Send it.
    return, formData, httpOptions)
      .catch((e) => {
        // handle me

But i get Wrong Response that i don’t want.

angular/ionic wrong response that i don't want

NB: OTP Providers Documentation NOTE: The request should be sent as POST Parameters in Body

What will be the right wey in IONIC/ANGULAR/POSTMAN(JSON Type) to getting right Resonse that i getting as POSTMAN first Screenshot ?

Get rid of httpHeaders entirely. You do not need to micromanage Content-Type with Angular’s HttpClient.

1 Like

Yeah it works , but what about ionic native ? is the same think works in ionic native HTTP too ?