Jump to content

Advice on how to send a http "PUT" command from a plugin


BillOatman
Go to solution Solved by BillOatman,

Recommended Posts

BillOatman

I have the following C# line that seems to work properly to send a string formatted as json :

 

 using (var client = new HttpClient())
 {
    var httpContent = new StringContent(data, Encoding.UTF8, "application/json");                
    response  = client.PutAsync(new Uri(sceneUrl), httpContent).Result;            
 }

What would produce the same thing in the plugin httpclient interface ?

 

I tried this:

                await _httpClient.SendAsync(new HttpRequestOptions
                {
                    Url = url,
                    RequestContent = jsonData.AsMemory(),
                    RequestContentType = "application/json"
                }, "PUT");

Would I need to put the json elements of the string into this call of HttpRequestOptions or something?

public void SetPostData(IDictionary<string, string> values);

Right now the receiver is not understanding the command from the plugin.  When I look at both requests in wireshark, the C# one shows the data going out as an object and the plugin is not.

Edited by BillOatman
Link to comment
Share on other sites

That seems to look correct. what are the differences in the response bodies?

Link to comment
Share on other sites

  • Solution
BillOatman

Uggggggggg. It's always the stupid things.  I didn't have quotes around a string value in the json.

Thanks for looking :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...