如何编写使用RestFixture POST / PUT请求 [英] How to write POST / PUT requests using RestFixture

查看:265
本文介绍了如何编写使用RestFixture POST / PUT请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用smartrics-RestFixture-3.0-bin.zip为发表的要求,但它的失败的某些原因。看起来像一个服务问题本身,但正​​如我在学习Fitnees,不知道什么是错的测试也是如此。

I am trying to use smartrics-RestFixture-3.0-bin.zip for POST request but it's failing for some reason. Looks like a service problem itself but as I am learning Fitnees, not sure if anything is wrong with the Test as well.

任何人都可以请您分享一些细节,例如或使用演示使用REST API的RestFixture /维基格式的POST请求休息 - 的 http://www.thomas-bayer.com/sqlrest/CUSTOMER/

Can anyone please share some details, or example for POST rest request using RestFixture/Wiki format using Demo REST APIs - http://www.thomas-bayer.com/sqlrest/CUSTOMER/

我的维基基于TC看起来像下面 - (我想用ID添加客户数据= 20)

'''Trying to add customer 20 entry'''
!| smartrics.rest.fitnesse.fixture.FitRestFixture | http://www.thomas-bayer.com/sqlrest/CUSTOMER/ |
| setBody | <CUSTOMER xmlns:xlink="http://www.w3.org/1999/xlink"><ID>20</ID><FIRSTNAME>Anne1</FIRSTNAME><LASTNAME>Miller1</LASTNAME><STREET>201 Upland Pl.</STREET><CITY>Lyon1</CITY></CUSTOMER> |
| POST    | /20| 200 | | |

我收到以下错误:

<html><head><title>Apache Tomcat/7.0.26 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.26</h3></body></html>

请建议。谢谢!

更新时间:2015年4月6日

Updated: 6 April 2015

我试图用POST方法,该方法是不正确的添加新客户进入,我应该使用PUT方法。今天,当我试图用PUT方法来添加新的客户进入,我得到了同样的错误:( ..

I was trying to add new CUSTOMER entry using POST method which was incorrect, I should have used PUT method. Today when I tried using PUT method to add new CUSTOMER entry, I got same error :(..

貌似只有Web服务的一个问题。

Looks like a problem with WEB Service only.

推荐答案

我已经得到了同样的错误之前,我加入setHeaders节我的wiki。
试试这个setBody后:

I've got the same error before I added setHeaders section to my wiki. Try this after setBody:

| setHeaders |内容类型:应用程序/ XML |

| setHeaders|Content-Type: application/xml|

希望这有助于。

这篇关于如何编写使用RestFixture POST / PUT请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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