✅ powershell post MultipartContent weird behavior
simply put, i'm making a request and content is serialized with type name instead of real content
with wireshark i see in the request this is sending that content is serialized as
System.Net.Http.StringContent System.Net.Http.StringContent
and i've got no clue on how to solve this
maybe remove everything and just send the body as string
powershell is 5.1
on my machine it works™️, on the one i need to execute the script it doesn't
edit apparently it doesn't work on my machine either? im pretty sure it used to work1 Reply
well apparently this works
so something went stupidly wrong
ok found something
when i create [System.Net.Http.MultipartFormDataContent]::new() in a function it doesn't work
when i create on the main scope it works
wtf
i got it
this is the error
$mc = [System.Net.Http.MultipartFormDataContent]::new()
in some weird way it doesn't actually return anything
thanks for the help, myself
i never thought powershell was such crap
days to figure out this thing, powershell gives no error, no warnings
and even then, no idea about how to make this work
sometimes object is fine, sometimes not
examples and doc around internet don't help
this is a nightmare
other evidence (in the furnace)
when i do new-object multipartformdatacontent and then .Add(stringcontent) it's ok
but if i do that in a function, it returns the stringcontent
why 😭
maybe i understood
you have to use return (,$value)
i have no idea why they should do this
this makes no sense, why change a universal standard in programming
have a particular way to express that a function should return a specific value
explained just as a note in an about
who tf would ever guess the return keyword is the problem in a function
this took me like a day? almost? to figure out
like i don't know who came up with this but it's one of the most stupid and unintuitive things i've seen on this planet
and stuff gets even crazier
but who cares