如何将纯 json 数据发布到服务堆栈休息服务 [英] how to post plain json data to service stack rest service
本文介绍了如何将纯 json 数据发布到服务堆栈休息服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我用来将 json 数据发布到 rest ful 服务的代码
Below is the code I am using to post json data to a rest ful service
var client = new JsonServiceClient(BaseUri);
var client = new JsonServiceClient(BaseUri);
Todo d = new Todo(){Content = "Google",Order =1, Done = false };
var s = JsonSerializer.SerializeToString < Todo>(d);
// client.Post<string>("/Todos/", "[{\"content\":\"YouTube\"}]");
// string payload= "[{\"id\":2,\"content\":\"abcdef\",\"order\":1,\"done\":false}]";
// string payload = @"{""todo"":{ {""content"":""abcdef"",""order"":1}} }";
client.Post<string>("/todos/", s);
我尝试传递普通的 json 数据,但它继续发送消息错误数据".然后我尝试 serizliing 也不起作用的实体.
I tried passing plain json data , it keep on fialing with message "Bad data". Then i tried serizliing the entity that also didn't work.
推荐答案
您可以使用 PostJsonToUrl,它包含在 ServiceStack.Text 中.
You can use PostJsonToUrl, which is included in ServiceStack.Text.
这篇关于如何将纯 json 数据发布到服务堆栈休息服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文