# Http API POST request response with nothing

**URL:** <https://forum.rasa.com/t/http-api-post-request-response-with-nothing/11804>\
**Category:** Rasa Open Source\
**Created:** [June 20, 2019, 7:33am UTC](https://forum.rasa.com/t/http-api-post-request-response-with-nothing/11804 "2019-06-20T07:33:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![CathyWang53](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@CathyWang53](https://forum.rasa.com/u/CathyWang53)\
**Post date:** [June 20, 2019, 7:33am UTC](https://forum.rasa.com/t/http-api-post-request-response-with-nothing/11804/1 "2019-06-20T07:33:27Z")

</div>

Hi everyone, I am new to rasa and http server. I met with a problem recently:

I tried to use Java language to send post request to my rasa server, although it works well with Get request, **but for the POST request, rasa response with nothing**.

I used `rasa init` to create a new project and didn’t change any files. Then I ran rasa by `rasa run --enable_api`

I tried post requests including [Run an action in a conversation](http://rasa.com/docs/rasa/api/http-api/#tag/Tracker/paths/~1conversations~1%7Bconversation_id%7D~1execute/post) and [Parse a message using the Rasa model](http://rasa.com/docs/rasa/api/http-api/#tag/Model/paths/~1model~1parse/post). I sent Json same to the ones shown on the screen, and send message to `http://xxx.xxx.xxx.xxx:5005//conversations/default/excute` and `http://xxx.xxx.xxx.xxx:5005//model/parse`.

However, my rasa just send me nothing: no errors or message, but only empty.

The get request works well, and my rasa model runs well in the shell.

Do anyone have some ideas about the possible reasons? Any help will be appreciated!🙏

Thanks!!

---

<div class="post-metadata">

**Author:** ![Tanja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tanja/32/4696_2.png) [@Tanja](https://forum.rasa.com/u/Tanja)\
**Post date:** [June 24, 2019, 1:00pm UTC](https://forum.rasa.com/t/http-api-post-request-response-with-nothing/11804/2 "2019-06-24T13:00:30Z")

</div>

How does your request look like?

I’m using the latest Rasa version and followed the steps you mentioned. After I started the Rasa server, I send the following request to it:

```auto
curl -X POST \
  http://localhost:5005/model/parse \
  -H 'Content-Type: application/json' \
  -d '{
    "text": "Hello!"
}'

```

That request returns the following response:

```auto
{
    "intent": {
        "name": "greet",
        "confidence": 0.9682487249
    },
    "entities": [],
    "intent_ranking": [
        {
            "name": "greet",
            "confidence": 0.9682487249
        },
        {
            "name": "mood_great",
            "confidence": 0.0384795777
        },
        {
            "name": "deny",
            "confidence": 0
        },
        {
            "name": "affirm",
            "confidence": 0
        },
        {
            "name": "mood_unhappy",
            "confidence": 0
        },
        {
            "name": "goodbye",
            "confidence": 0
        }
    ],
    "text": "Hello!"
}

```

Also the other endpoint you mentioned returns a proper answer:

```auto
curl -X POST \
  'http://localhost:5005/conversations/default/execute?include_events=AFTER_RESTART' \
  -H 'Content-Type: application/json' \
  -d '{"name":"utter_greet"}'

```

---

<div class="post-metadata">

**Author:** ![CathyWang53](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@CathyWang53](https://forum.rasa.com/u/CathyWang53)\
**Post date:** [July 1, 2019, 6:12am UTC](https://forum.rasa.com/t/http-api-post-request-response-with-nothing/11804/3 "2019-07-01T06:12:11Z")

</div>

Hi, Tanja. Thanks for your reply.

I tried the request the same with yours:

```auto
curl -X POST \
  http://localhost:5005/model/parse \
  -H 'Content-Type: application/json' \
  -d '{
    "text": "Hello!"
}'

```

But the request returns:

`An error occurred while handling an error`

However, if I send this request:

```auto
curl -X GET http://localhost:5005/

```

It returns the right response:

```auto
hello from Rasa: 0.15.0a1

```

Do you know why GET request works well but POST cannot? Thanks!!🙏

---

<div class="post-metadata">

**Author:** ![CathyWang53](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@CathyWang53](https://forum.rasa.com/u/CathyWang53)\
**Post date:** [July 1, 2019, 6:39am UTC](https://forum.rasa.com/t/http-api-post-request-response-with-nothing/11804/4 "2019-07-01T06:39:05Z")

</div>

I just found that, for the GET request:

```auto
curl -X GET http://localhost:5005/domain

```

It also returns a weird answer as follow:

```auto
{
  "version":"0.15.0a1",
  "status":"failure",
  "message":"Invalid Accept header. Domain can be provided as json \
                    (\"Accept: application\/json\") or yml (\"Accept: application\/x-yml\"). \ 
                    Make sure you've set the appropriate Accept header.",
  "reason":"InvalidHeader",
  "details":{},"help":null,"code":406
}

```

Do you have any idea about it? Thank you.

---

<div class="post-metadata">

**Author:** ![ameid](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@ameid](https://forum.rasa.com/u/ameid)\
**Post date:** [July 1, 2019, 6:42am UTC](https://forum.rasa.com/t/http-api-post-request-response-with-nothing/11804/5 "2019-07-01T06:42:12Z")

</div>

> [@CathyWang53](#):
>
> ```auto
> curl -X GET http://localhost:5005/domain
> 
> ```

Can you try this instead:

```auto
curl -X GET -H "Accept: application/json" http://localhost:5005/domain

```

---

<div class="post-metadata">

**Author:** ![CathyWang53](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@CathyWang53](https://forum.rasa.com/u/CathyWang53)\
**Post date:** [July 1, 2019, 6:49am UTC](https://forum.rasa.com/t/http-api-post-request-response-with-nothing/11804/7 "2019-07-01T06:49:12Z")

</div>

Yes it works. Thanks a lot, Ameid!

Could you please help me with the POST problems? 🥺

---

<div class="post-metadata">

**Author:** ![Tanja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tanja/32/4696_2.png) [@Tanja](https://forum.rasa.com/u/Tanja)\
**Post date:** [July 2, 2019, 2:57pm UTC](https://forum.rasa.com/t/http-api-post-request-response-with-nothing/11804/8 "2019-07-02T14:57:47Z")

</div>

Can you start the server in debug mode `rasa run --enable-api --debug` and check if there is any error printed to the console when you are making the POST request?

---

<div class="post-metadata">

**Author:** ![CathyWang53](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@CathyWang53](https://forum.rasa.com/u/CathyWang53)\
**Post date:** [July 3, 2019, 8:00am UTC](https://forum.rasa.com/t/http-api-post-request-response-with-nothing/11804/9 "2019-07-03T08:00:09Z")

</div>

Hi Tanja, thanks a lot for your help!

I have solved some problems through your help, so now my rasa server works well when I use post and get request in the shell.

However, if I send the post request through Java language, still, the get request works well but POST can get no response. I used the debug mode and the bug information is:

```auto
2019-07-03 15:46:48 DEBUG rasa.server - Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sanic/request.py", line 149, in load_json
    self.parsed_json = loads(self.body)
ValueError: Unexpected character found when decoding 'true'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/rasa/server.py", line 801, in parse
    data = emulator.normalise_request_json(request.json)
  File "/usr/local/lib/python3.6/site-packages/sanic/request.py", line 143, in json
    self.load_json()
  File "/usr/local/lib/python3.6/site-packages/sanic/request.py", line 153, in load_json
    raise InvalidUsage("Failed when parsing body as json")
sanic.exceptions.InvalidUsage: Failed when parsing body as json

```

There might be some problems with the entity of post request, but I cannot find it… I wonder if you might have some ideas. The post and get request codes in Java are shown here:

```auto
public static String post(String url, Map<String, Object> params){
		HttpClient client = HttpClients.createDefault();
		HttpPost post = new HttpPost(url);
		post.addHeader("Content-Type","application/json");
		//set parameters
      List<NameValuePair> list = new ArrayList<NameValuePair>();  
      for(Entry<String, Object> e : params.entrySet()){
    	    list.add(new BasicNameValuePair(e.getKey(),String.valueOf(e.getValue())));
      	}
      try {
	      if(list.size() > 0){  
	          UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list,"UTF-8");  
	          post.setEntity(entity);  
	        }
	      HttpResponse response = client.execute(post);
	      HttpEntity entity = response.getEntity();
			StatusLine statusLine = response.getStatusLine();
			if(statusLine.getStatusCode() == HttpStatus.SC_OK){
				String content = EntityUtils.toString(entity, "UTF-8");
				if(content == null){
					content = "";
				}
				return content;
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return "";
}

```

```auto
public static String get(String url){
		HttpClient client = HttpClients.createDefault();

		HttpGet get = new HttpGet(url);
		get.addHeader("Content-Type","application/json");
		try {
			HttpResponse response = client.execute(get);
			HttpEntity entity = response.getEntity();
			StatusLine statusLine = response.getStatusLine();
			if(statusLine.getStatusCode() == HttpStatus.SC_OK){
				String content = EntityUtils.toString(entity, "UTF-8");
				if(content == null){
					content = "";
				}
				return content;
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return "";
}

```

Thanks!

---

<div class="post-metadata">

**Author:** ![CathyWang53](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@CathyWang53](https://forum.rasa.com/u/CathyWang53)\
**Post date:** [July 4, 2019, 8:10am UTC](https://forum.rasa.com/t/http-api-post-request-response-with-nothing/11804/10 "2019-07-04T08:10:00Z")

</div>

I have found the reason.

For the post request in Java, I should use `StringEntity` to set the entity instead of `EntityUtils`. Or the entity is not able to be detected by rasa. Also, I need to set the header of the get & post requests.

Thanks a lot for the help from you all! 😄

---

<div class="post-metadata">

**Author:** ![anita](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@anita](https://forum.rasa.com/u/anita)\
**Post date:** [July 12, 2020, 5:26am UTC](https://forum.rasa.com/t/http-api-post-request-response-with-nothing/11804/11 "2020-07-12T05:26:50Z")

</div>

you can simply use ReqBin and send requests to the server right from your browser. it’s easy and free
