# HTTP POST Request key

**URL:** <https://forum.ionicframework.com/t/http-post-request-key/209205>\
**Category:** Ionic Framework\
**Created:** [May 7, 2021, 12:27pm UTC](https://forum.ionicframework.com/t/http-post-request-key/209205 "2021-05-07T12:27:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArinaAmir](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/arinaamir/32/136523_2.png) [@ArinaAmir](https://forum.ionicframework.com/u/ArinaAmir)\
**Post date:** [May 7, 2021, 12:27pm UTC](https://forum.ionicframework.com/t/http-post-request-key/209205/1 "2021-05-07T12:27:59Z")

</div>

Hi all,

The question is not really related to the Ionic Framework, however…

I have one might be very simple question. I have to do a POST Request to check voucher validity. The post request uses URL Params only (without value with key only) and I am confused how to manage it from the app?  
If someone of you have any idea or solution it will be highly appreciated!!!  
Here is what I am trying to achieve:

This is the API endpoint which I have to call ( passing **application\_module** and **voucher** values)

> [https://xyz/api/check\_voucher/application\_module/voucher](https://xyz/api/check_voucher/application_module/voucher)

What I have tried so far:

```
 let urlSearchParams = new URLSearchParams ();
 urlSearchParams.append('', 'myapplicationmodule/');
 urlSearchParams.append('', "myvouchercode");

```

return this.httpClient.post(environment.url, urlSearchParams );

**Second attempt:**

```auto
 let application_module = 'xyz/';
 let voucher = 'xyz'
 return this.httpClient.post(environment.url, application_module + voucher );

```

None of above mentioned methods have success. 😕

I am so confused how to achieve this POST call without key… Is there any way to do that?

Thanks in advance guys!!

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [May 7, 2021, 7:02pm UTC](https://forum.ionicframework.com/t/http-post-request-key/209205/2 "2021-05-07T19:02:06Z")

</div>

You’ve nailed two of the ways to pass things in URLs, so all that leaves is door #3: in the path itself.

Your first attempt is what you do when the backend wants something `application/x-www-form-urlencoded`. Your second try put it in the body of the request - what you want when the backend wants JSON. Option #3:

```auto
let url = `https://xyz/api/check_voucher/${application_module}/${voucher}`;
return this.httpClient.post(url);

```

If you have access to whoever designed this backend API, however, I would take a moment to ask them why they did it this way, though. Accepting as JSON in the body (your #2) would be far and away my first choice here, because the other two options put the specific information in the URL itself, which means it tends to get recorded in server logs (typically not desired in for something like this).

---

<div class="post-metadata">

**Author:** ![ArinaAmir](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/arinaamir/32/136523_2.png) [@ArinaAmir](https://forum.ionicframework.com/u/ArinaAmir)\
**Post date:** [May 10, 2021, 8:48am UTC](https://forum.ionicframework.com/t/http-post-request-key/209205/3 "2021-05-10T08:48:33Z")

</div>

> [@rapropos](#):
>
> ```auto
> let url = `https://xyz/api/check_voucher/${application_module}/${voucher}`;
> return this.httpClient.post(url);
> 
> ```

thanks a lot 💌
