Post request improvement

Hi i need to set that as postadata but openbullet2 won’t accept .

<?xml version="1.0" encoding="UTF-8"?><request><Index>-1</Index><Phones><Phone><input.DATA></Phone></Phones><Sca></Sca><Content><message></Content><Length><mlength></Length><Reserved>1</Reserved><Date><Time></Date></request>

The only way i find is to do like that, maybe you have some ideas to improve this:

string topost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><Index>-1</Index><Phones><Phone>"[email protected]+"</Phone></Phones><Sca></Sca><Content>"+@message+"</Content><Length>"+@mlength+"</Length><Reserved>1</Reserved><Date>"+@Time+"</Date></request>";

    BLOCK:HttpRequest
      url = "http://example.com/send"
      method = POST
      TYPE:STANDARD
      @tosend
      "application/x-www-form-urlencoded"
    ENDBLOCK

Hey, there is currently no escaping for < and > (last time I tried to fix the regex to implement it I broke the entire logic of interpolated strings). Please use C# directly to interpolate you string like

string topost = $"<?xml version=\"1.0\" [...] <Length>{mlength}</Length>"

Find out more here $ - string interpolation - C# reference | Microsoft Docs

1 Like