How to access Online Database using Blueprint?

I personally make this by using this plugins (avalaible on marketplace for free I think) GitHub - ufna/VaRest: REST API plugin for Unreal Engine 4 - we love restfull backend and JSON communications! , maybe there a better solution but this is the only one I have to suggest.

With this you can post some value to your php, after make your php search inside your SQL database and finally read the answer inside BP to do whatever you want :p.

I´ve tried googling this, but didn´t find anything to help me with this. How i can access php files from online database, using blueprint?

Thanks Xosh, but i´ve read this once, but i don´t get it how and where i “install” this. Which file i need to download? There is no explanation there.

Using blueprints only, there is no possibilities, you have to code it in C++ (I made it as an actor component) or you have to use VaRest, and the install guide is in its wiki page.

Give me a few hours and I’ll explain every step. It is not that much complicated but it also take me some time to get it right.

Hey here how I use VaRest Plugins. First you need to install it to your project, I can’t explain this better than this page done => GitHub - ufna/VaRest: REST API plugin for Unreal Engine 4 - we love restfull backend and JSON communications! . Now you have the plugins and you can use it in any BP normaly. Just need to right click and write Va Rest to see all options provide by the plugins.

Now a small exemple how to use VaRest in image.

  1. You need to use «Construct Json Object», You will need one for the entire field and the desire number for the value you need to send. After you get your node, promote it to a variable.

96441-construct.jpg

  1. Now you need to set those variable and build an array.

96442-array.jpg

96443-set+field.jpg

  1. Next step is to set your request. You will need to choose «Construct Json Request» and use POST as Verb and Json as Content Type, after this promote the return value to a new variable call Request. Now you need the following nodes=> Set Request Object and Get Response Object. Take the output of the Request Variable to the Target of the 2 node above and bring the «ParentJson = first variable» value to the Json Object of «Set Request Object».

  1. We are close to the end! Now you need to create a Bind event to OnRequestComplete and OnRequestFail, You’ll also need a Process URL with the link of Your script (I use localhost in this exemple, but you could stock the IP in a variable and reuse it). Take the output of Request and bring it to all the subsequent Target. I also add you the way to see if you have an incoherent value inside your request or a bug inside your PHP.

Now you can «Get string Field» and use the good field name to get the desire value.

(Image in comment)

  1. Last thing you need to know is inside your PHP you need this =>

    <?php $json = json_decode(file_get_contents('php://input')); //allow you to get all content $value_1 = $json->data[0]->Object1; // get the object in question (table start to 0) $value_2 = $json->data[1]->Object2; echo json_encode(array('YourValue1'=>$value_1, 'YourValue2'=>$value_2)); //don't forget to re-encode the array ?>

Have a good day and tell me if you have problem with this!

Really Thanks.

I´ll try to follow this tutorial and i´ll tell you if it worked for me.

I got this error message and I dont´t understand what is the problem.

LogPlayLevel: UnrealBuildTool: -------- End Detailed Actions Stats -----------------------------------------------------------
LogPlayLevel: UnrealBuildTool: ERROR: UBT ERROR: Failed to produce item: C:\Users\bruno\Documents\Bruno\Servicos\AplicativoAgendall\Arquivos\UNREAL\Agendall\Binaries\Android\Agendall-armv7-es2.so
LogPlayLevel: UnrealBuildTool: Total build time: 22,97 seconds
LogPlayLevel: CommandUtils.Run: Run: Took 23,110472s to run UnrealBuildTool.exe, ExitCode=5
LogPlayLevel: Program.Main: ERROR: AutomationTool terminated with exception: AutomationTool.AutomationException: Command failed (Result:5): C:\Program Files\Epic Games\4.11\Engine\Binaries\DotNET\UnrealBuildTool.exe Agendall Android Development -Project=C:\Users\bruno\Documents\Bruno\Servicos\AplicativoAgendall\Arquivos\UNREAL\Agendall\Agendall.uproject C:
Users\bruno\Documents\Bruno\Servicos\AplicativoAgendall\Arquivos\UNREAL\Agendall\Agendall.uproject -remoteini=“C:\Users\bruno\Documents\Bruno\Servicos\AplicativoAgendall\Arquivos\UNREAL\Agendall” -noxge -NoHotReloadFromIDE -ignorejunk. See logfile for details: ‘UnrealBuildTool-2016.06.30-23.17.38.txt’
LogPlayLevel: em AutomationTool.CommandUtils.RunAndLog(String App, String CommandLine, String Logfile, Int32 MaxSuccessCode, String Input, ERunOptions Options, Dictionary2 EnvVars) LogPlayLevel: em AutomationTool.CommandUtils.RunUBT(CommandEnvironment Env, String UBTExecutable, String CommandLine, String LogName, Dictionary2 EnvVars)
LogPlayLevel: em AutomationTool.UE4Build.BuildWithUBT(String TargetName, UnrealTargetPlatform TargetPlatform, String Config, FileReference UprojectPath, Boolean ForceMonolithic, Boolean ForceNonUnity, Boolean ForceDebugInfo, Boolean ForceFlushMac, Boolean DisableXGE, String InAddArgs, Boolean ForceUnity, Dictionary2 EnvVars) LogPlayLevel: em AutomationTool.UE4Build.Build(BuildAgenda Agenda, Nullable1 InDeleteBuildProducts, Boolean InUpdateVersionFiles, Boolean InForceNoXGE, Boolean InUseParallelExecutor, Boolean InForceNonUnity, Boolean InForceUnity, Boolean InShowProgress, Dictionary2 PlatformEnvVars) LogPlayLevel: em Project.Build(BuildCommand Command, ProjectParams Params, Int32 WorkingCL, ProjectBuildTargets TargetMask) LogPlayLevel: em BuildCookRun.DoBuildCookRun(ProjectParams Params) LogPlayLevel: em AutomationTool.BuildCommand.Execute() LogPlayLevel: em AutomationTool.Automation.Execute(List1 CommandsToExecute, CaselessDictionary1 Commands) LogPlayLevel: em AutomationTool.Automation.Process(String[] CommandLine) LogPlayLevel: em AutomationTool.Program.MainProc(Object Param) LogPlayLevel: em AutomationTool.InternalUtils.RunSingleInstance(Func2 Main, Object Param)
LogPlayLevel: em AutomationTool.Program.Main()
LogPlayLevel: Program.Main: AutomationTool exiting with ExitCode=5 (5)
LogPlayLevel: Domain_ProcessExit
LogPlayLevel: copying UAT log files…
LogPlayLevel: Completed Launch On Stage: Build Task, Time: 23.765762
LogPlayLevel: BUILD FAILED
PackagingResults:Error: Error Launch failed! Unknown Error

Oh, and this:

MetaData mismatch. Did you assign a stat to two groups? New //STATGROUP_Threads//FLauncherTask///Thread_4504_0///####STATCAT_Advanced#### old //STATGROUP_Threads//FLauncherTask///Thread_21e0_0///####STATCAT_Advanced####

I’m not the good person for this kind of error, if I understand well you try to compile the plugins with the editor? Maybe you can try to simply add it externally. The only thing I can recommend for your error is to make sure you take compatible branch for the editor and plugins. sorry I cannot help you more than this.

Hey Xosh, How to store the data retrieved from database into variables?

How to Post data into database by varest and php script?