在编程中抛出400错误的Restful service post方法url [英] Restful service post method url using in programming throwing 400 error

查看:147
本文介绍了在编程中抛出400错误的Restful service post方法url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

post方法的操作方法(费用项目是类):



 WebInvoke(方法:=   POST,UriTemplate:=   CreateExpenseItem,RequestFormat:= WebMessageFormat.Json,ResponseFormat:= WebMessageFormat.Json,BodyStyle:= WebMessageBodyStyle.Bare)_ 
Function CreateExpenseItem( ByVal objExpense As ExpenseItem) As 整数



实施方法:

 公共 功能 CreateExpenseItem( ByVal  objExpense < span class =code-keyword> As  ExpenseItem) As   Integer   Implements  IHrmsService.CreateExpenseItem 
Dim 输出正如 整数
输出= objEmployee.SaveExpenseDetails _
(_
objExpense.ExpensemasterID,objExpense.ExpenseID,
objExpense.Expensename,_
objExpense.ExpenseDate,_
objExpense.Amount,objExpense.Description,_
objExpense.EmpID _

返回输出
结束 功能



使用时发生400错误代码中的url但我可以使用Get方法:



http://116.145.199.252/ServiceHRMS/HrmsService.svc/web/CreateExpenseItem



请有人帮助我..



我做错了什么?

解决方案

Operation method for post method (Expense item is class) :

WebInvoke(Method:="POST", UriTemplate:="CreateExpenseItem", RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Bare) _
Function CreateExpenseItem(ByVal objExpense As ExpenseItem) As Integer


Implementation method :

Public Function CreateExpenseItem(ByVal objExpense As ExpenseItem) As Integer Implements IHrmsService.CreateExpenseItem
        Dim Output As Integer
        Output = objEmployee.SaveExpenseDetails _
                                       ( _
                                               objExpense.ExpensemasterID,objExpense.ExpenseID, 
                                               objExpense.Expensename, _
                                               objExpense.ExpenseDate, _
                                               objExpense.Amount, objExpense.Description, _
                                               objExpense.EmpID _
                                       )
      Return Output
 End Function


It is throwing 400 error while using through url in code but Im able to use Get methods :

http://116.145.199.252/ServiceHRMS/HrmsService.svc/web/CreateExpenseItem

Please can anyone help me ..

What Im I doing wrong ?

解决方案

这篇关于在编程中抛出400错误的Restful service post方法url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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