让一个C#客户端使用bottle.py从python Web服务请求数据。 [英] Have a C# client requesting data from a python web service using bottle.py.

查看:252
本文介绍了让一个C#客户端使用bottle.py从python Web服务请求数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的瓶子网络服务无法接受要处理的数据,也无法弄清楚问题是什么。

怀疑路由语句和相应的def语句不正确。



它返回:远程服务器返回错误:(500)内部服务器错误。)

我需要一些帮助来解决这个问题路径和def语句应该是什么。

如果c#代码是正确的。



这是拨打电话的客户端代码。



My bottle web service is not able to accept data to process, and am not able to figure out what the problem is.
am suspecting that the route statement and the corresponding def statement is not correct.

It returns:The remote server returned an error: (500) Internal Server Error.)
I need some help to figure this out what the route and def statement should be.
if the c# code is correct.

Here is the client code making the call.

using (var client = new WebClient())
    {
    	var obj = new Dictionary<string, string>()
    	{
    		{"MemberOid", "564d783b54355e2070173117"},
    		{"ConnectionName", "mongodb://100.19.6.122"},
    		{"DBName", "NATHANDB"}
    	};
    	var dataString = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
    	client.Headers[HttpRequestHeader.ContentType] = "application/json";
    	var response = client.UploadString("http://localhost:8080/" + "getData", "POST", dataString);
    } 





这是Web服务的一部分,带有route / def语句。





Here is the section of the web service, with the route/def statement.

@route('/getData', method='POST')
def getScore(updatedata):
    data = request.body.readline()
    ...
    ...





任何帮助将不胜感激。

谢谢。



any help will be appreciated.
thanks.

推荐答案

使用request.json :) http:/ /bottlepy.org/docs/0.10/api.html?highlight=json#bottle.BaseRequest.json [ ^ ]
use request.json :) http://bottlepy.org/docs/0.10/api.html?highlight=json#bottle.BaseRequest.json[^]


这篇关于让一个C#客户端使用bottle.py从python Web服务请求数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆