Okay I’ve tried everything and I still can’t figure this out. I have this method here, which converts @param keys and @param values into key/value pairs in a JSON object and is supposed to post it to @param URL:
void ASteamHandler::sendPostRequest(FString URL, FString eventKey, TArray<FString> keys, TArray<FString> values)
{
TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
activeEventKey = eventKey;
for (int i = 0; i < keys.Num(); i++)
{
FString key = keys*;
FString value = values*;
JsonObject->SetStringField(key, value);
}
FString OutputString;
TSharedRef<TJsonWriter<TCHAR>> JsonWriter = TJsonWriterFactory<TCHAR>::Create(&OutputString);
FJsonSerializer::Serialize(JsonObject.ToSharedRef(), JsonWriter);
TSharedRef<IHttpRequest> HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetVerb("POST");
HttpRequest->SetURL(URL);
HttpRequest->SetHeader("Content-Type", "application/json");
HttpRequest->SetContentAsString(OutputString);
HttpRequest->OnProcessRequestComplete().BindUObject(this, &ThisClass::OnResponseReceived);
HttpRequest->ProcessRequest();
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, OutputString);
UE_LOG(LogTemp, Warning, TEXT("%s"), *OutputString);
}
As you can see, I log the JSON object out at the end of the method. I can confirm that the JSON object is being created properly, and that all of the information is correct; however, according to my server, nothing is POSTed at all. $_POST is just an empty array.
Am I missing something?