如何使用 RestFixture 编写 POST/PUT 请求 [英] How to write POST / PUT requests using RestFixture
问题描述
我正在尝试将 smartrics-RestFixture-3.0-bin.zip 用于 POST 请求,但由于某种原因它失败了.本身看起来像是服务问题,但当我正在学习 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/Wiki 格式的 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/
我的基于 wiki 的 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 日
我试图使用不正确的 POST 方法添加新的 CUSTOMER 条目,我应该使用 PUT 方法.今天,当我尝试使用 PUT 方法添加新的 CUSTOMER 条目时,我遇到了同样的错误:(..
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屋!