Reputation: 1815
I have a working example of webClient.UploadDataAsync(Uri addr, string method, byte[] data)
in WPF, it calls a RESTful api and works well.
Now I want to call the same RESTapi in silverlight, unfortunately WebClient in Silverlight only has the method of webClient.UploadStringAsync(Uri addr, string method, string data)
How can I pass the byte array as a string parameter?
Upvotes: 1
Views: 2170
Reputation: 564413
In Silverlight, the way to upload binary data is via WebClient.OpenWriteAsync. This asynchronously opens a writable stream, which can then be used to upload the file (in the event handler).
For a full sample, including code, see this post.
Upvotes: 1