Help with url variable and body data in rest api endpoints

Hi,
I’m struggling with something, wich is maybe not feasable …
I have the following endpoint :

$Route = New-UDEndpoint -Url "/stuff/Something/:id" -Method PUT -Endpoint {
    param($id,$Body)
    $x = $Body | ConvertFrom-Json
    $body
    $x.data >> c:\tmp\data.log
}

as you see i’m trying to get the data from the id variable (works fine), and retrieve data from the body (they are sent as json).

There is something in the body, but i can not convert it from json ! but if i output body back to the reponse, i get the correct json :frowning:

Maybe it’s a bug ? maybe i can not do what i’m trying to do ? My problem is that i want to send a structured data to the route, so form is out of question. (or am i wrong ?? i’m still learning here ! )

Anyway! You’ve made something great Adam! thanks for the hard work !

I found an alternate way to pass the data but ,i’ll let you judge:
via postman (but this will be the same with PS) i use form-data, a key, for example “id” and the value will look like name=NAME1;data=somestuff then i can fetch it with $request.form["id"] -split ';' the thing is that, i need to pass multiple ids, sometimes, so i thought that a well formatted json was the best way…

Again, i’m still learning so maybe i’m doing something wrong here, or missing some concepts… !

Ok my bad i did not understand correcetly the stuff … it is working fine … :slight_smile: i’m just dumb :slight_smile: