# Http Post request with uri

**URL:** <https://forums.unrealengine.com/t/http-post-request-with-uri/459492>\
**Category:** C++\
**Tags:** httprequest, unreal-engine, http, UE4, CPP, question\
**Created:** [December 13, 2019, 2:34pm UTC](https://forums.unrealengine.com/t/http-post-request-with-uri/459492 "2019-12-13T14:34:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![isaacvega](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@isaacvega](https://forums.unrealengine.com/u/isaacvega)\
**Post date:** [December 13, 2019, 2:34pm UTC](https://forums.unrealengine.com/t/http-post-request-with-uri/459492/1 "2019-12-13T14:34:15Z")

</div>

Hi,

Can someone explain me how can I define in C++ the following requests for a RestFul API.

POST

```
POST my_index/_doc
{
    "name" : "Tom",
    "operation" : {
      "message" : "trying out Elasticsearch"
    }
}

```

GET

```
GET my_index/_search
{
  "query": {
    "match_all": {}
  }
}

```

It is not clear where the “my\_index/\_search” part is included (afaik, that’s the uri field).  
If I add it to the content, I get no response from the server.

Should I include the uri as part of the or what’s the correct way?

This is the code I am using to create the requests, as you can read I don’t know how to define the “my\_index/\_search” section.

```
	TSharedRef<IHttpRequest> Request = Http->CreateRequest();
	Request->SetHeader(TEXT("Content-Type"), TEXT("application/"));
	Request->SetURL(TEXT("https://user:pass@mywebservice:443"));

	Request->SetVerb(TEXT("GET"));
        FString content(TEXT("{\"query\": {\"match_all\": {}}}"));
	Request->SetContentAsString(content);

	Request->OnProcessRequestComplete().BindUObject(this, &AKMGameMode::OnResponseReceived);
	Request->ProcessRequest();

```

Regards

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [December 13, 2019, 10:50pm UTC](https://forums.unrealengine.com/t/http-post-request-with-uri/459492/2 "2019-12-13T22:50:17Z")

</div>

When you input URI to browser or any other HTTP application it is divided in 2 parts, to server it needs to connect to and content it needs to request (or post) when connected. so if you input `example.com/data/something`, HTTP application will attempt to connect to `example.com` and then gonna send `GET data/something` request if it was successful.

So you should embed it to URL:

```
https://user:pass@mywebservice:443/my_index/_search

```

---

<div class="post-metadata">

**Author:** ![isaacvega](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@isaacvega](https://forums.unrealengine.com/u/isaacvega)\
**Post date:** [December 15, 2019, 4:12pm UTC](https://forums.unrealengine.com/t/http-post-request-with-uri/459492/3 "2019-12-15T16:12:19Z")

</div>

Thank you for your answer!  
Is there official doc in the Unreal describing how to use this feature or is it something that is assumed to be known from web dev?

I tried connecting appending the data you mention above and I don’t get a server answer at all. I can send you a full log, but this is the first error reported

```
request failed, libcurl error: 52 (Server returned nothing (no headers, no data))

```

Also, tried using SetContentAsStreamedFile or SetContentAsString, getting the same results.  
The file content is this one

```
{
 "query": {
    "match_all": {}
  }
}

```

Appreciate you help

EDIT: I think that in whatever form I add Content, that generates an error. Maybe am missing another step to send data?
