How to write POST / PUT requests using RestFixture

旧街凉风 提交于 2019-12-12 03:09:42

问题


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.

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/

My wiki based TC looks like below - (I am trying to add Customer data with 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 | | |

I am getting below Error:

<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>

Please suggest. thanks!

Updated: 6 April 2015

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 :(..

Looks like a problem with WEB Service only.


回答1:


Is the service working normally, do you get a different response if you send the same body to it some other way? (When I send your body to the same url I get the same error.)

The error seems to suggest that the service you are calling is broken. Sometimes this can also be the result of incorrect usage.

As it stands your question seems to have less to do with FitNesse and more with the service you are using.




回答2:


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

| setHeaders|Content-Type: application/xml|

Hope this helps.



来源:https://stackoverflow.com/questions/29427367/how-to-write-post-put-requests-using-restfixture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!