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->SetContentAsString("{\"username\":xxxxxxxx}");
request->OnProcessRequestComplete().BindUObject(this, &UAClass::ReceivedAuth);
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.