C#消费web api - 意思是云 [英] C# consuming web api - meaningcloud

查看:90
本文介绍了C#消费web api - 意思是云的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用网络API时遇到了一些麻烦,我尝试了一些不同的格式来进行通话,但是我得到了错误(错误代码406)



  我的代码

protected void Button1_Click( object sender,EventArgs e)
{
var client = new RestClient( http://api.meaningcloud.com/class-1.1\" );
var request = new RestRequest(Method.POST);
request.AddHeader( content-type application / x-www-form-urlencoded);
request.AddParameter( application / x-www-form-urlencoded key = MY_KEY_VALUE1b& txt = PRUEBA& model = IPTC_es,ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
txtRespuesta.Text = response.Content;
}


响应


<! DOCTYPE HTML PUBLIC - // IETF // DTD HTML 2.0 // EN >
< html>< head>
< title> 406不可接受< / title >
< / head > <身体GT;
< h1>不可接受< / h1 >
< p>在 1
class =code-keyword>此
服务器。< / p >
可用的变体:
< ul>
< li>< a href = class-1.1.php> class-1。 1 .php < / a > ,键入application / x-httpd-php < / li >
< / ul >
< hr>
< address> Apache / 2. 4 7 (Ubuntu)api服务器。 meaningcloud.com端口 80 < / 地址 >
< / body > < / html >


任何想法我做错了什么?

感谢 您的时间

我尝试过:

尝试更改方法 响应。< / hr >

解决方案

你知道云意味着有一个支持页面,对吗?

支持| MeaningCloud [ ^ ]

他们是这方面的专家,所以为什么不尝试在那里发布你的问题?



还有一个测试控制台,你可以在那里试试你的请求并获得正确的参数。

主题提取2.0控制台| MeaningCloud [ ^ ]

Hi, i have some trouble consuming a web api, i try some diferents formats for call but im stil getting errors (error code 406)

This is my code 

  protected void Button1_Click(object sender, EventArgs e)
    {
        var client = new RestClient("http://api.meaningcloud.com/class-1.1");
        var request = new RestRequest(Method.POST);
        request.AddHeader("content-type", "application/x-www-form-urlencoded");
        request.AddParameter("application/x-www-form-urlencoded", "key=MY_KEY_VALUE1b&txt=PRUEBA&model=IPTC_es", ParameterType.RequestBody);
        IRestResponse response = client.Execute(request);
        txtRespuesta.Text = response.Content;
    }


This is the response


<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>406 Not Acceptable</title>
</head><body>
<h1>Not Acceptable</h1>
<p>An appropriate representation of the requested resource /class-1.1 could not be found on this server.</p>
Available variants:
<ul>
<li><a href="class-1.1.php">class-1.1.php</a> , type application/x-httpd-php</li>
</ul>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at api.meaningcloud.com Port 80</address>
</body></html>


Any idea what im doing wrong?

Thanks for your time

What I have tried:

I try change the method for the response.</hr>

解决方案

You do know that meaning cloud has a support page, right?
Support | MeaningCloud[^]
They are experts on this so why not try to post your question there?

The also have a test console where you can try out your request and get the parameters correct.
Topics Extraction 2.0 Console | MeaningCloud[^]


这篇关于C#消费web api - 意思是云的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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