hey and thank you for helping…
So i started building this in relation to https://answers.unrealengine.com/questions/165223/fhttpmodule-usage-issues.html
First I started with the build.cs:
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class LoginTest : ModuleRules
{
public LoginTest(TargetInfo Target)
{
PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "HTTP" });
PrivateDependencyModuleNames.AddRange(new string] { "HTTP" });
PrivateIncludePathModuleNames.AddRange(new string] { "HTTP" });
}
}
I created a UBlueprintFunctionLibrary like this .h:
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Runtime/Online/HTTP/Public/Http.h"
#include "Http.h"
#include "IHttpRequest.h"
#include "HttpWrapper.generated.h"
/**
*
*/
UCLASS()
class LOGINTEST_API UHttpWrapper : public UBlueprintFunctionLibrary
{
GENERATED_UCLASS_BODY()
UFUNCTION(BlueprintCallable, Category = "HttpWrapper")
void completedHTTPRequest(FHttpRequestPtr request, FHttpResponsePtr response, bool bWasSuccessful);
UFUNCTION(BlueprintCallable, Category = "HttpWrapper")
void createRequest();
};
And here the .cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "LoginTest.h"
#include "HttpWrapper.h"
#include "IHttpRequest.h"
void UHttpWrapper::createRequest()
{
TSharedRef<IHttpRequest> Request = FHttpModule::Get().CreateRequest();
Request->SetVerb(TEXT("POST"));
Request->SetURL("http://www....");
// setcontent-type to whatever you want
Request->SetHeader("Content-Type", "application/json");
Request->SetContentAsString("...");
// bind a function which gets called when the request is completed
Request->OnProcessRequestComplete().BindUObject(this, &UHttpWrapper::completedHTTPRequest);
if (!Request->ProcessRequest())
{
// HTTP request failed
}
}
void UHttpWrapper::completedHTTPRequest(FHttpRequestPtr request, FHttpResponsePtr response, bool bWasSuccessful)
{
if (!response.IsValid())
{
// no valid response
}
else if (EHttpResponseCodes::IsOk(response->GetResponseCode()))
{
// valid response
FString msg = response->GetContentAsString();
}
else
{
// HTTP request error
}
}
But Visual Studio is coming up with this error and I cannot find a solution
error : In HttpWrapper: Unrecognized type 'FHttpRequestPtr'