I have been trying to fix this for a while, but to no success, which is why I have come to here to hopefully get an answer to what is going wrong. I am writing a little tool so our team can submit bugs to Trello through the game itself. I have set this up and it sort of works, sort of meaning it only works on the first play session after opening the engine, all the following play sessions will work only partly.
It works perfectly during the first play session (but only in engine, not in a packaged build). Every following session, nothing seems to be called after Request.OnProcessRequestComplete() for whatever reason and I cannot figure out why. All of this is located inside of a singleton class for blueprint utilities.
Here is the code that is responsible for this
void UHttpUtilities::SubmitCardToTrello(const FString& CardName, const FString& CardDescription, const TArray<FString>& CardLabels, const FString& ImageFilePath)
{
ImagePath = ImageFilePath;
FHttpModule* Http = &FHttpModule::Get();
TSharedRef<IHttpRequest, ESPMode::ThreadSafe> Request = Http->CreateRequest();
FString LabelIDString;
for (const FString& Label : CardLabels)
{
LabelIDString += FString::Printf(TEXT("\"%s\", "), *Label);
}
if(LabelIDString.Len() > 0)
{
LabelIDString.RemoveAt(LabelIDString.Len() - 2, 2);
}
LabelIDString = FString::Printf(TEXT("[%s]"), *LabelIDString);
const FString URL = FString::Printf(TEXT("https://api.trello.com/1/cards?idList=%s&key=%s&token=%s"), *CardListID, *APIKey, *APIToken);
Request->SetURL(URL);
Request->SetVerb("POST");
Request->SetHeader("Content-Type", "application/json");
Request->SetHeader("Cache-Control", "no-cache");
Request->SetHeader("Pragma", "no-cache");
//Create request body
FString RequestBody = FString::Printf(TEXT(
"{ \"name\": \"%s\", \"desc\": \"%s\", \"idList\": \"%s\", \"key\": \"%s\", \"token\": \"%s\", \"idLabels\": %s }"),
*CardName, *CardDescription, *CardListID, *APIKey, *APIToken, *LabelIDString);
Request->SetContentAsString(RequestBody);
Request->OnProcessRequestComplete().BindUObject(this, &UHttpUtilities::OnResponseReceived);
if(Request->ProcessRequest())
{
UE_LOG(LogTemp, Warning, TEXT("Trello request sent successfully."));
}
else
{
UE_LOG(LogTemp, Error, TEXT("Failed to send Trello request!"));
}
}
If anyone has any clue, I would much appreciate it!