# The image is not being posted to api in ionic

**URL:** <https://forum.ionicframework.com/t/the-image-is-not-being-posted-to-api-in-ionic/137262>\
**Category:** ionic-v3\
**Created:** [August 3, 2018, 10:28am UTC](https://forum.ionicframework.com/t/the-image-is-not-being-posted-to-api-in-ionic/137262 "2018-08-03T10:28:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksujanpaul](https://avatars.discourse-cdn.com/v4/letter/k/c2a13f/32.png) [@ksujanpaul](https://forum.ionicframework.com/u/ksujanpaul)\
**Post date:** [August 3, 2018, 10:28am UTC](https://forum.ionicframework.com/t/the-image-is-not-being-posted-to-api-in-ionic/137262/1 "2018-08-03T10:28:40Z")

</div>

I’m working on the ionic application which uses POST API. And I am feeding that POST API with an image/blob but not taking that image into it. If the api took the image then it’ll return a string as an output and it should be visible in the HomePage in ionic.

Here is the code.

```auto
givetoapi(){
  var uploadingImage = new Image();
  uploadingImage.src = "../assets/imgs/banana.jpg";
  let headers = new Headers();
  headers.append('content-type','image/*');
  let url = 'http://af46cff3.ngrok.io';
  let postData = JSON.stringify({
    key :'predimg',
    value :uploadingImage.src
  })
  let data:Observable<any> = this.http.post(url,postData)
  data.subscribe((result) => {
    console.log(result)

```

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [August 3, 2018, 10:35am UTC](https://forum.ionicframework.com/t/the-image-is-not-being-posted-to-api-in-ionic/137262/2 "2018-08-03T10:35:49Z")

</div>

So what exactly is not working?

The code you posted uses a variable `downloadingImage` that doesn’t seem to exist.

---

<div class="post-metadata">

**Author:** ![ksujanpaul](https://avatars.discourse-cdn.com/v4/letter/k/c2a13f/32.png) [@ksujanpaul](https://forum.ionicframework.com/u/ksujanpaul)\
**Post date:** [August 3, 2018, 11:36am UTC](https://forum.ionicframework.com/t/the-image-is-not-being-posted-to-api-in-ionic/137262/3 "2018-08-03T11:36:09Z")

</div>

yeah @Sujan12 i’ve changed that check that again.

The issue is the `uploadingImage` is not being taken by the POST API.

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [August 3, 2018, 11:43am UTC](https://forum.ionicframework.com/t/the-image-is-not-being-posted-to-api-in-ionic/137262/4 "2018-08-03T11:43:47Z")

</div>

> [@ksujanpaul](#):
>
> The issue is the `uploadingImage` is not being taken by the POST API.

What does that mean? Does the server not know what to do with what it receives? Doesn’t it receive anything? Doesn’t the code POST anything? Is the variable even empty before you try to post?

---

<div class="post-metadata">

**Author:** ![ksujanpaul](https://avatars.discourse-cdn.com/v4/letter/k/c2a13f/32.png) [@ksujanpaul](https://forum.ionicframework.com/u/ksujanpaul)\
**Post date:** [August 3, 2018, 8:59pm UTC](https://forum.ionicframework.com/t/the-image-is-not-being-posted-to-api-in-ionic/137262/5 "2018-08-03T20:59:38Z")

</div>

it is not receiving the image i am sending through the application @Sujan12

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [August 3, 2018, 9:27pm UTC](https://forum.ionicframework.com/t/the-image-is-not-being-posted-to-api-in-ionic/137262/6 "2018-08-03T21:27:49Z")

</div>

So the variable is filled, the app is correctly sending it, but the server is not receiving the it?  
Then this is a server bug and has nothing to do with Ionic.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:26pm UTC](https://forum.ionicframework.com/t/the-image-is-not-being-posted-to-api-in-ionic/137262/7 "2021-07-19T21:26:15Z")

</div>


