使用C#消费Oracle ORDS RESTful API

时间:2019-01-16 09:56:01

标签: c# oracle rest webservice-client oracle-ords

关于使用C#使用ORDS Oracle RESTful数据服务,我得到以下响应。

  

{       状态码:405,       ReasonPhrase:“不允许使用方法”,       版本:1.1,       内容:System.Net.Http.StreamContent,       标头:       {           内容长度:11402           内容类型:text / html       }

public void test()
{
    string item_code;

    using(var client = new HttpClient())
    {
        Item items = new Item
        {
            segment1 = "049002932",
            description = "Fine Liner Dollar Pointer Softliner Metal Jacket F 0.3 Black 10's Box",
            short_description = " Pointer F Black 10's Box", service_item = "No", primary_uom_code = "10", inventory_item_status_code = "Inactive"
        };

        client.BaseAddress = new Uri("http://10.132.1.40:8090/");

        var response = client.PutAsJsonAsync("ords/ebsvis1/raz_inv/raz_item/Update/", items).Result;

        if (response.IsSuccessStatusCode)
            Console.Write("Success");
        else
            Console.Write("Error");
    }
}

这是我的RESTful服务定义:

enter image description here

1 个答案:

答案 0 :(得分:0)

对于基于ORDS的RESTful服务,您是否为raz_inv模块和... / Update /模板定义了PUT处理程序?

根据您的屏幕截图,这是PUT Hander URI:

/raz_inv/raz_item/update/{item_code}

但是,您正在

上进行PUT
/raz_inv/raz_item/Update/

您需要在URI的末尾包含项目代码,所以

var response client.PutAsJsonAsync("ords/ebsvis1/raz_inv/raz_item/Update/049002932",  items).Result;

只需猜测049002932位...