VaRest
VaRest copied to clipboard
How Can I use this plugin in C++ not BP
Any Tips or sample ?
OK.... I have solved this...
this is my sample to use VaRestSubsystem Callurl. Use UVaRestSubsystem as singleton to create RequestObject ,ResponseObject, RequestJsonObject
And another is the same as this sample.,like post a json body ,set header...and so on. .h
FVaRestCallDelegate CallDelegate;
UFUNCTION()
void CallBack(UVaRestRequestJSON* Request);
.cpp
void AJsonActor::BeginPlay()
{
Super::BeginPlay();
UVaRestSubsystem* VaRestSubsystem=GEngine->GetEngineSubsystem<UVaRestSubsystem>();
auto JsonObject = VaRestSubsystem->ConstructVaRestJsonObject();
CallDelegate.BindDynamic(this,&AJsonActor::CallBack);
VaRestSubsystem->CallURL(TEXT("URL"),EVaRestRequestVerb::GET,EVaRestRequestContentType::x_www_form_urlencoded_url,JsonObject,CallDelegate);
}
void AJsonActor::CallBack(UVaRestRequestJSON* Request)
{
UE_LOG(LogTemp,Warning,TEXT("Request Response is %s"),*Request->GetResponseObject()->EncodeJson());
}
No this is not a good way of getting the Subsystem
It should be done like this
UVaRestSubsystem* VaRestSubsystem = GEngine->GetEngineSubsystem<UVaRestSubsystem>();
No this is not a good way of getting the Subsystem It should be done like this
UVaRestSubsystem* VaRestSubsystem = GEngine->GetEngineSubsystem<UVaRestSubsystem>();
AllRight... it's better!!! Thanks!
I want to know the JsonObject how to pass parameters
i get it, all my problem is done