# WebSDK2 HandleRequest

**URL:** <https://forum.xojo.com/t/websdk2-handlerequest/70843>\
**Category:** Web SDK\
**Created:** [June 22, 2022, 6:00am UTC](https://forum.xojo.com/t/websdk2-handlerequest/70843 "2022-06-22T06:00:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Hüttenberger](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/82dd89/32.png) [@Daniel\_Hüttenberger](https://forum.xojo.com/u/Daniel_H%C3%BCttenberger)\
**Post date:** [June 22, 2022, 6:00am UTC](https://forum.xojo.com/t/websdk2-handlerequest/70843/1 "2022-06-22T06:00:57Z")

</div>

Hi there,

I’m in the process to wrap some third party controls.  
The grid control I’m using can automatically fetch data from a url. So I wan’t to provide the data through an embedded api.

I read about the “HandleRequest(Request as WebRequest, Response as WebResponse) As Boolean” event in the sdk which seems to fit exactly my needs.

So I’m setting the rest url of my grid to the following: `window.location.href + "/sdk/" + this.controlID()`  
The request arrives correctly BUT not inside the HandleRequest event of the control. But inside the HandleUrl event of the app.

I’m not handling anything in the HandleUrl event. So it should be routed to my control.

Please can someone push me into the right direction?

Sincerly  
Daniel

---

<div class="post-metadata">

**Author:** ![Attilio\_Punzi](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@Attilio\_Punzi](https://forum.xojo.com/u/Attilio_Punzi)\
**Post date:** [June 22, 2022, 6:33am UTC](https://forum.xojo.com/t/websdk2-handlerequest/70843/2 "2022-06-22T06:33:04Z")

</div>

Hi Daniel,

Within the class that extends XojoWeb.XojoVisualControl in the updateControl method try something like:

```auto
let el = this.DOMElement();
 if (!el)
   return;
     const url = window.location.protocol + '//' + window.location.host + '/sdk/' + el.id + '/Request';

```

NB: If you add your control via .AddControl there is a [bug](https://tracker.xojo.com/xojoinc/xojo/-/issues/68606) that does not allow you to call HandleRequest. You have to necessarily add it via IDE.

---

<div class="post-metadata">

**Author:** ![Daniel\_Hüttenberger](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/82dd89/32.png) [@Daniel\_Hüttenberger](https://forum.xojo.com/u/Daniel_H%C3%BCttenberger)\
**Post date:** [June 22, 2022, 6:45am UTC](https://forum.xojo.com/t/websdk2-handlerequest/70843/3 "2022-06-22T06:45:01Z")

</div>

Thank you Attilio,

I think I puzzled it down.  
You can use the following javascript to build a correct url `XojoWeb.SessionURL() + "/data/" + this.ControlID()`  
Keep in mind you have to use “data” and not “sdk” in the path. I you use “sdk” the request is not arriving the control.

[@Xojo](https://forum.xojo.com/groups/xojo) Please update the documentation for the WebSDK.  
I think this Tool is awesome and we could do amazing things with a good SDK. But the lack of documentation/examples is awful.

---

<div class="post-metadata">

**Author:** ![Attilio\_Punzi](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@Attilio\_Punzi](https://forum.xojo.com/u/Attilio_Punzi)\
**Post date:** [June 22, 2022, 6:51am UTC](https://forum.xojo.com/t/websdk2-handlerequest/70843/4 "2022-06-22T06:51:39Z")

</div>

I have always used /sdk/ and it has always worked. If you open the example attached to the feedback case you can verify that it works. (I did not put the js code in the class but in the show event, but nothing changes).

If you replace /sdk/ with /data/ in that project it no longer works.

---

<div class="post-metadata">

**Author:** ![Daniel\_Hüttenberger](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/82dd89/32.png) [@Daniel\_Hüttenberger](https://forum.xojo.com/u/Daniel_H%C3%BCttenberger)\
**Post date:** [June 22, 2022, 7:21am UTC](https://forum.xojo.com/t/websdk2-handlerequest/70843/5 "2022-06-22T07:21:07Z")

</div>

So I figured it out.  
Another rule learned (should be placed in the documentation!! [@Xojo](https://forum.xojo.com/groups/xojo) )

I used a absolute url with the XojoWeb.SessionURL() + “/sdk” + this.ControlID().  
That’s wrong.  
Using a relative url like “/sdk/” + this.ControlID() it’s working.

Thank you @Attilio_Punzi

---

<div class="post-metadata">

**Author:** ![Attilio\_Punzi](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@Attilio\_Punzi](https://forum.xojo.com/u/Attilio_Punzi)\
**Post date:** [June 22, 2022, 7:23am UTC](https://forum.xojo.com/t/websdk2-handlerequest/70843/6 "2022-06-22T07:23:24Z")

</div>

@Daniel_Hüttenberger Glad to have been helpful 😉
