# Why does the engine crash when I POST data to a server?

I am working on communications between my game and a cloud database. I'm working on the authentication part but when I try to pass data to the server in a POST the engine crashes. If I pass in a simple string like "username" it does not crash and I get an error response from the server as expected. But when I try to pass in a JSON string the engine crashes. Here is my code:

OnAuthCookieResponse = cookieResponseDelegate;
TSharedRef<IHttpRequest> request = FHttpModule::Get().CreateRequest();
FString url = NewObject<UURLBuilder>()
->Host(BASE_URL)
->Path(SESSION)
->Build();

request->SetURL(url);
request->SetVerb("POST");
request->ProcessRequest();


The stack trace points me to line 559 in CurlHttp.cpp. IsURLEncoded() returns false which causes the check() to fail.

check(!GetHeader("Content-Type").IsEmpty() || IsURLEncoded(RequestPayload));


However when the engine passes data here, IsURLEncoded() returns true and the check() passes. Here is a sample of some data from the engine that passes. You can see it is a JSON string.

Here is what my data looks like that causes the engine to crash

You can see they are both JSON strings but mine causes the check to fail. I have also tried to completely URL encode the JSON string and the check still fails.

# So why does this fail for me but passes when used by the engine?

{ and } are not valid URL characters, so your JSON is not URLEncoded. I bet the engine is sending a content type of application/json, which then bypasses the Url-Encoding check.