Basic HTTP Request from a BlueprintCallable Node

Hi,

I’m trying to make a basic HTTP Request using a BlueprintCallable node, and I can’t make it work.
I’ve read and followed some tutorials and came up with a working “BP Actor” in game doing the HTTP Request, but now i want it to work with a single callable blueprint node like this (without the Target input) :

138898-cpp_bpnode.png

I’ve been on this for days now, and I still can’t make it work.

Here’s what I got now :

.h :

.cpp :

The problem is, on the .h file. If I don’t put a “static” on my void, the blueprint node ask me for a “Target” in input.
I Don’t know what “Target” he wants exactly to put here, So I put the void on static.
But now, as you can see on the .cpp file, some variables like HTTP or the “this” reference can’t be used anymore on this static void.

I’m very bad on CPP, so i’d by glad if someone could help me with this ! Thanks

can you try removing tab before “static”? maybe it’s confusing UHT

Thanks for you answer. I tried it, but it didn’t work.
I don’t think that’s the problem, it’s normal that it doesn’t work. I understand that I can’t call non-static parameters of an object in a static function.

Ah sorry i missunderstood your quastion ^^" ok here comes the real anwser

Normally you call function on a object right? By making function static you make it callable without a objectneeded, but still function be in class namespace… this effectively also means you can’t access “this” because you not calling from object anymore, so there is no “this” naymore. You say yourself, you don’t want that “Target” pin, but without it you can’t deliver “this” variable to the function.

In other words you can access only static and global functions from static functions, same goes with varables.

So in your case instead of using http variable you need to use FHttpModule::Get() (which is also static function) direclly, all save it up in local variable.

Changing the Http Var for a “FHttpModule::Get()” still doesn’t work (its not accepted), and i’d still get the “this” problem that I can’t use.

FHttpModule::Get() should work it’s static

It’s returning reference so make sure you using “.” instead of ->", and as i said you can still use http var, just declere it as local variable inside function.

Sorry didn’t notice binding. There no way to get “this” in static, again object you trying to access does not exist, so you need to find alternative methods. In case of event, you can turn OnResponceRecived in to static, and use BindStatic instead of BindUObject.

If i’m not mistaken blueprint supports passing of delegates as arguments too, which you can bind with blueprint events, but i’m not sure if all delegates are supported, you might try research on that too.

Thank you, This actually works!

I’ll post the new (working) code here. It might help someone in the futur =)

.h :

.cpp :

Hi, i just read your answer because i have the same problem. But the last posts (working code) you put on ".h : " the .cpp image. The .cpp image is two times.