Reputation: 21
As I know ,the urlread function can post to the URL. I did it with the string.
urlread(url, 'Post', {'userId', userid, 'Password', Password}
but There are some JSON value like that:
"country": ["US","JP"],
"student": false,
I tried this code but it failed.
urlread(url,'Post',{'userId', userid ,'Password' ,Password ,'country' ,'{'US' ,'JP'}' ,'student' ,false}
How can I POST data from Matlab to a RESTful server in JSON format?
Upvotes: 2
Views: 1223
Reputation: 22245
You'll find that urlread
has been replaced by webread and webwrite and that it automatically handles JSON serialization. So you can just create a Matlab struct and hand that to webwrite
.
url = 'http://example.com'
data = struct('userId', userId ,'Password' , password, 'country', {'US', 'JP'}, 'student', false)
webwrite(url, data);
Upvotes: 1