Since the last update 0.9.7.41 callbacks for RestApi requests are broken.
It seems that there is no strong reference set to the callback so the callback object gets destroyed immediatly.
string a = "https://webhook.site/xxxxxxxxx"; RestContext ctx = GetGame().GetRestApi().GetContext(a); auto myCbThatWontBeTriggered = RestCallback2(); ctx.POST(myCbThatWontBeTriggered, "","bla data");
A workaround is to give the callback a strong reference by your own via an array/map or so.
ref array<ref RestCallback2> GlobalCbBuffer = {}; void TestFnc() { string a = "https://webhook.site/xxxxxxxxx"; RestContext ctx = GetGame().GetRestApi().GetContext(a); auto myCbThatWillBeTriggeredNow = RestCallback2(); GlobalCbBuffer.Insert(myCbThatWillBeTriggeredNow); ctx.POST(myCbThatWillBeTriggeredNow , "","bla data"); } TestFnc();
In addition to that it occurs an error sometimes during compiling:
SCRIPT : Reloading game scripts SCRIPT : Script validation SCRIPT (E): Leaked 'RestContext' script instance (1x)! SCRIPT : Compiling GameLib scripts SCRIPT : Compiling Game scripts