使用Web API [英] Working with Web API

查看:70
本文介绍了使用Web API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我是使用Web Api工作的新手,我目前正在使用Docusign网络Api。

这里webApi需要以json或XML的形式发送参数,我想在这里使用Json。

我使用HttpClient对象传递凭据并调用HttpClient对象的GetAsync()方法APi。

此调用的结果使用''HttpResponseMessage''处理。





现在我想要调用post和put方法。

所以我将使用PostAsJsonAsync()和PutAsJsonAsync()函数。



我有创建了一个Dictionary< string,>()对象,我将参数及其值添加到它。

然后我正在使用,

string Jsonstring = JsonConvert.SerializeObject (DictionaryObject);

这给了我预期的Json。



现在因为我需要传递json参数和函数调用。
任何人都可以帮我知道如何传递参数。



提前谢谢。

Hi All,

I am a newbie to working with Web Api and I am currently working with the Docusign web Api.
The webApi here requires to send the parameters as json or XML and I want to use Json here.
I am using HttpClient object for passing the credentials and calling the GetAsync() method of the HttpClient object the web APi.
The result of this call is processed using ''HttpResponseMessage''.


Now I want to call post and put methods.
So I will be using the the PostAsJsonAsync() and PutAsJsonAsync() functions.

I have created a Dictionary<string,>() object and I am adding the parameters and its values to it.
Then I am using,
string Jsonstring= JsonConvert.SerializeObject(DictionaryObject);
This gives me the Json as expected.

Now since I need to pass the json parameters along with the function calls.
Can anyone help me know how to pass the parameter.

Thanks in advance.

推荐答案

使用



PostAsJsonAsync(requestUri,DictionaryObject)
Use

PostAsJsonAsync(requestUri, DictionaryObject)


这篇关于使用Web API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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