Wiremock 1.57 returning Eof Exception when multiple endpoints are added - wiremock

I have two stub endpoints added in wiremock. Below is the output of http://localhost:56789/__admin
{
"mappings": [
{
"request": {
"urlPath": "/encryption/v1/decrypt/",
"method": "GET"
},
"response": {
"status": 0,
"body": "{\"message\":null,\"httpStatus\":0,\"status\":{\"httpStatusCode\":200,\"success\":true,\"errors\":[]},\"_metaData\":{\"urlParams\":{}},\"debugData\":null,\"data\":[\"01125851014\",\"01125851014\",\"debraj.manna#jabong.com\",\"03325853088\",\"03325853088\",\"debraj.manna#rediffmail.com\"],\"httpStatusToBeReturned\":200}"
}
},
{
"request": {
"urlPath": "/orders/v1/ordersearch/",
"method": "GET"
},
"response": {
"status": 200,
"body": "{\"message\":null,\"httpStatus\":0,\"status\":{\"httpStatusCode\":200,\"success\":true,\"errors\":null},\"_metaData\":{\"urlParams\":{}},\"data\":{\"order\":[{\"addmismatch\":1,\"address\":[{\"add1\":\"testaddress1\",\"add2\":\"\",\"addtype\":\"0\",\"altphone\":\"\",\"city\":\"Gurgaon\",\"comp\":\"\",\"country\":\"\",\"custaddreg\":\"\",\"firstname\":\"testFirst\",\"midname\":\"\",\"lastName\":\"testLast\",\"isbill\":1,\"phone\":\"9zMoRQYv8fPYMHokQ3Z83+8//mGW5IbDjRTArpSvmW0=\",\"postcode\":\"122001\",\"prefix\":\"\",\"shippartagent\":0},{\"add1\":\"Shipping\",\"add2\":\"Updated\",\"addtype\":\"0\",\"altphone\":\"01125851014\",\"city\":\"Kadamtala\",\"comp\":\"\",\"country\":\"\",\"custaddreg\":\"\",\"firstname\":\"Tested\",\"midname\":\"\",\"lastName\":\"Tested\",\"isbill\":0,\"phone\":\"9zMoRQYv8fPYMHokQ3Z83+8//mGW5IbDjRTArpSvmW0=\",\"postcode\":\"744103\",\"prefix\":\"\",\"shippartagent\":0}],\"affpartner\":1,\"appversion\":\"\",\"ccavenueord\":\"\",\"ccretrial\":0,\"corpcurrvalue\":\"0.00\",\"corpordiden\":\"\",\"corptransid\":\"\",\"couponcode\":\"\",\"created\":\"\",\"customer\":{\"email\":\"zryLbw62xF5dLFujFTFAyRVgyY3jQtA6gjJNOXb6N80=\",\"id\":11584369,\"iscorporate\":\"\",\"firstname\":\"LEGACY\",\"lastname\":\"LEGACY\",\"phone\":\"\",\"sessionId\":\"\",\"idMd5\":null},\"deviceid\":\"\",\"finance\":{\"codcharge\":null,\"grandtotal\":\"975.00\",\"shipamnt\":\"100.00\",\"shipdisamnt\":null,\"taxamnt\":\"15.97\",\"gwamnt\":null},\"gift\":{},\"invoice\":{\"file\":\"\",\"num\":\"\"},\"ip\":\"205.147.97.67\",\"isrecur\":0,\"items\":[{\"addtext\":\"\",\"addwarehouse\":\"\",\"bitmap\":\"\",\"bundpackid\":\"\",\"bundpckidfier\":\"\",\"cancelAmt\":\"\",\"catatroptglobordty\":\"\",\"disccap\":\"\",\"discounts\":{\"bunddisc\":\"0.00\",\"cartruledisc\":\"0.00\",\"coupcat\":0,\"coupmonval\":\"0.00\",\"coupprcnt\":0,\"gccreditval\":\"1.00\",\"storcredit\":\"0.00\"},\"disploc\":\"Warehouse\",\"disptime\":3,\"dlvtime\":\"7-8\",\"expdilvdate\":\"2016-03-21 0:00:00\",\"finance\":{\"corpcurrval\":\"\",\"custcost\":\"\",\"lastamtpd\":\"\",\"orguntpr\":\"\",\"paidPr\":\"774.00\",\"paybkcrval\":\"\",\"shipcharge\":\"100.00\",\"taxAmt\":\"0.00\",\"taxpercent\":\"0.00\",\"untpr\":\"775.00\",\"vatamt\":\"0.00\",\"storcredit\":null,\"invinctax\":0.0,\"taxrate\":0.0,\"spextax\":0.0,\"collectamt\":0.0,\"commrate\":0.0,\"commamt\":0.0,\"recComm\":0.0,\"splservicecharge\":0.0},\"holidaycnt\":\"\",\"iscancel\":0,\"iscancelable\":1,\"iscancelmsg\":\"\",\"iscod\":0,\"iscustom\":0,\"isdatechange\":0,\"isfreebie\":0,\"isgiftwrap\":0,\"ispbkref\":0,\"isreturn\":0,\"isreturnable\":0,\"issurface\":1,\"isreturnmsg\":\"\",\"isvatchard\":0,\"isxchang\":0,\"isxchangmsg\":\"\",\"itemId\":70969623,\"lastStatusDate\":\"2016-03-11 15:07:24\",\"margin\":\"\",\"merchant\":\"\",\"mercorder\":\"\",\"mod\":\"\",\"mop\":\"\",\"mpmerchant\":\"\",\"name\":\"Narangi & Nagkesar Facial Ubtan 50 Gms\",\"notbuy\":\"\",\"packid\":\"\",\"packqty\":\"\",\"pbkearn\":\"\",\"preordcampname\":\"\",\"preorddispdt\":\"\",\"processtime\":\"\",\"refmoney\":\"0.00\",\"refvouch\":\"0.00\",\"returnAmt\":\"\",\"rewdpts\":\"\",\"ruledispname\":\"\",\"ship\":{\"carrier\":0,\"expshppart\":\"\",\"ismultiship\":\"\",\"shipment\":\"\",\"shipty\":\"Own Warehouse\",\"statchange\":\"\",\"splservicetype\":null,\"splserviceexpectdeldate\":null},\"shipliabty\":\"\",\"sku\":\"FO009BE75LEAINDFAS-447108\",\"skubundle\":0,\"status\":\"cancelled_cc\",\"weight\":\"\",\"qty\":1,\"created\":null,\"sellersku\":\"123232\",\"SellerId\":0},{\"addtext\":\"\",\"addwarehouse\":\"\",\"bitmap\":\"\",\"bundpackid\":\"\",\"bundpckidfier\":\"\",\"cancelAmt\":\"\",\"catatroptglobordty\":\"\",\"disccap\":\"\",\"discounts\":{\"bunddisc\":\"0.00\",\"cartruledisc\":\"0.00\",\"coupcat\":0,\"coupmonval\":\"0.00\",\"coupprcnt\":0,\"gccreditval\":\"0.00\",\"storcredit\":\"0.00\"},\"disploc\":\"Warehouse\",\"disptime\":3,\"dlvtime\":\"7-8\",\"expdilvdate\":\"2016-03-21 0:00:00\",\"finance\":{\"corpcurrval\":\"\",\"custcost\":\"\",\"lastamtpd\":\"\",\"orguntpr\":\"\",\"paidPr\":\"875.00\",\"paybkcrval\":\"\",\"shipcharge\":\"100.00\",\"taxAmt\":\"0.00\",\"taxpercent\":\"0.00\",\"untpr\":\"875.00\",\"vatamt\":\"0.00\",\"storcredit\":null,\"invinctax\":0.0,\"taxrate\":0.0,\"spextax\":0.0,\"collectamt\":0.0,\"commrate\":0.0,\"commamt\":0.0,\"recComm\":0.0,\"splservicecharge\":0.0},\"holidaycnt\":\"\",\"iscancel\":0,\"iscancelable\":1,\"iscancelmsg\":\"\",\"iscod\":0,\"iscustom\":0,\"isdatechange\":0,\"isfreebie\":0,\"isgiftwrap\":0,\"ispbkref\":0,\"isreturn\":0,\"isreturnable\":0,\"issurface\":1,\"isreturnmsg\":\"\",\"isvatchard\":0,\"isxchang\":0,\"isxchangmsg\":\"\",\"itemId\":70969624,\"lastStatusDate\":\"2016-03-11 15:08:18\",\"margin\":\"\",\"merchant\":\"\",\"mercorder\":\"\",\"mod\":\"\",\"mop\":\"\",\"mpmerchant\":\"\",\"name\":\"Tejasvi Milk Facial Ubtan 50 Gm\",\"notbuy\":\"\",\"packid\":\"\",\"packqty\":\"\",\"pbkearn\":\"\",\"preordcampname\":\"\",\"preorddispdt\":\"\",\"processtime\":\"\",\"refmoney\":\"0.00\",\"refvouch\":\"0.00\",\"returnAmt\":\"\",\"rewdpts\":\"\",\"ruledispname\":\"\",\"ship\":{\"carrier\":0,\"expshppart\":\"\",\"ismultiship\":\"\",\"shipment\":\"\",\"shipty\":\"Own Warehouse\",\"statchange\":\"\",\"splservicetype\":null,\"splserviceexpectdeldate\":null},\"shipliabty\":\"\",\"sku\":\"FO009BE76LDZINDFAS-447107\",\"skubundle\":0,\"status\":\"cancelled_cc\",\"weight\":\"\",\"qty\":1,\"created\":null,\"sellersku\":\"123232\",\"SellerId\":0}],\"mobileverf\":\"\",\"oldRef\":\"\",\"orderId\":41006021,\"orderNr\":\"160311346938664\",\"parentordid\":41006021,\"paymethod\":\"CcAvenue\",\"process\":\"\",\"ship\":{\"shipdelaydays\":0,\"partneragentname\":null,\"partneragentcode\":null,\"partneragentphone\":null},\"status\":{\"success\":false},\"storeid\":0,\"trsticket\":\"\",\"updated\":\"2016-03-11 15:08:13\",\"userdevtype\":\"mobile\",\"utmcampaignid\":\"\",\"domain\":\"wsoa\",\"earnmethod\":\"jrewards\",\"itemCustomization\":null,\"iscancel\":0,\"isreturn\":0,\"isxchang\":0,\"isPickup\":0,\"customerSegments\":null,\"odrstatus\":0,\"fkcorporatecustomer\":0,\"agentcampaign\":null},{\"addmismatch\":1,\"address\":[{\"add1\":\"testaddress1\",\"add2\":\"\",\"addtype\":\"0\",\"altphone\":\"\",\"city\":\"Gurgaon\",\"comp\":\"\",\"country\":\"\",\"custaddreg\":\"\",\"firstname\":\"testFirst\",\"midname\":\"\",\"lastName\":\"testLast\",\"isbill\":1,\"phone\":\"5Qa6Rwor34cuaLKgjskeQ3G/0WnGArDHSl/JmuMfwxA=\",\"postcode\":\"122001\",\"prefix\":\"\",\"shippartagent\":0},{\"add1\":\"Shipping\",\"add2\":\"Updated\",\"addtype\":\"0\",\"altphone\":\"01125851014\",\"city\":\"Kadamtala\",\"comp\":\"\",\"country\":\"\",\"custaddreg\":\"\",\"firstname\":\"Tested\",\"midname\":\"\",\"lastName\":\"Tested\",\"isbill\":0,\"phone\":\"5Qa6Rwor34cuaLKgjskeQ3G/0WnGArDHSl/JmuMfwxA=\",\"postcode\":\"744103\",\"prefix\":\"\",\"shippartagent\":0}],\"affpartner\":1,\"appversion\":\"\",\"ccavenueord\":\"\",\"ccretrial\":0,\"corpcurrvalue\":\"0.00\",\"corpordiden\":\"\",\"corptransid\":\"\",\"couponcode\":\"\",\"created\":\"\",\"customer\":{\"email\":\"NiJkjFQy2A6tySZAlxLKrVZtLQ2nbqm5WHbVrh9gMng=\",\"id\":11584369,\"iscorporate\":\"\",\"firstname\":\"LEGACY\",\"lastname\":\"LEGACY\",\"phone\":\"\",\"sessionId\":\"\",\"idMd5\":null},\"deviceid\":\"\",\"finance\":{\"codcharge\":null,\"grandtotal\":\"874.00\",\"shipamnt\":\"100.00\",\"shipdisamnt\":null,\"taxamnt\":\"15.97\",\"gwamnt\":null},\"gift\":{},\"invoice\":{\"file\":\"\",\"num\":\"\"},\"ip\":\"205.147.97.67\",\"isrecur\":0,\"items\":[{\"addtext\":\"\",\"addwarehouse\":\"\",\"bitmap\":\"\",\"bundpackid\":\"\",\"bundpckidfier\":\"\",\"cancelAmt\":\"\",\"catatroptglobordty\":\"\",\"disccap\":\"\",\"discounts\":{\"bunddisc\":\"0.00\",\"cartruledisc\":\"0.00\",\"coupcat\":0,\"coupmonval\":\"0.00\",\"coupprcnt\":0,\"gccreditval\":\"1.00\",\"storcredit\":\"0.00\"},\"disploc\":\"Warehouse\",\"disptime\":3,\"dlvtime\":\"7-8\",\"expdilvdate\":\"2016-03-21 0:00:00\",\"finance\":{\"corpcurrval\":\"\",\"custcost\":\"\",\"lastamtpd\":\"\",\"orguntpr\":\"\",\"paidPr\":\"774.00\",\"paybkcrval\":\"\",\"shipcharge\":\"100.00\",\"taxAmt\":\"0.00\",\"taxpercent\":\"0.00\",\"untpr\":\"775.00\",\"vatamt\":\"0.00\",\"storcredit\":null,\"invinctax\":0.0,\"taxrate\":0.0,\"spextax\":0.0,\"collectamt\":0.0,\"commrate\":0.0,\"commamt\":0.0,\"recComm\":0.0,\"splservicecharge\":0.0},\"holidaycnt\":\"\",\"iscancel\":0,\"iscancelable\":1,\"iscancelmsg\":\"\",\"iscod\":0,\"iscustom\":0,\"isdatechange\":0,\"isfreebie\":0,\"isgiftwrap\":0,\"ispbkref\":0,\"isreturn\":0,\"isreturnable\":0,\"issurface\":1,\"isreturnmsg\":\"\",\"isvatchard\":0,\"isxchang\":0,\"isxchangmsg\":\"\",\"itemId\":70969623,\"lastStatusDate\":\"2016-03-11 15:07:24\",\"margin\":\"\",\"merchant\":\"\",\"mercorder\":\"\",\"mod\":\"\",\"mop\":\"\",\"mpmerchant\":\"\",\"name\":\"Narangi & Nagkesar Facial Ubtan 50 Gms\",\"notbuy\":\"\",\"packid\":\"\",\"packqty\":\"\",\"pbkearn\":\"\",\"preordcampname\":\"\",\"preorddispdt\":\"\",\"processtime\":\"\",\"refmoney\":\"0.00\",\"refvouch\":\"0.00\",\"returnAmt\":\"\",\"rewdpts\":\"\",\"ruledispname\":\"\",\"ship\":{\"carrier\":0,\"expshppart\":\"\",\"ismultiship\":\"\",\"shipment\":\"\",\"shipty\":\"Own Warehouse\",\"statchange\":\"\",\"splservicetype\":null,\"splserviceexpectdeldate\":null},\"shipliabty\":\"\",\"sku\":\"FO009BE75LEAINDFAS-447108\",\"skubundle\":0,\"status\":\"cancelled_cc\",\"weight\":\"\",\"qty\":1,\"created\":null,\"sellersku\":\"123232\",\"SellerId\":0}],\"mobileverf\":\"\",\"oldRef\":\"\",\"orderId\":41006020,\"orderNr\":\"160311346396646\",\"parentordid\":41006020,\"paymethod\":\"CcAvenue\",\"process\":\"\",\"ship\":{\"shipdelaydays\":0,\"partneragentname\":null,\"partneragentcode\":null,\"partneragentphone\":null},\"status\":{\"success\":false},\"storeid\":0,\"trsticket\":\"\",\"updated\":\"2016-03-11 15:07:19\",\"userdevtype\":\"mobile\",\"utmcampaignid\":\"\",\"domain\":\"wsoa\",\"earnmethod\":\"jrewards\",\"itemCustomization\":null,\"iscancel\":0,\"isreturn\":0,\"isxchang\":0,\"isPickup\":0,\"customerSegments\":null,\"odrstatus\":0,\"fkcorporatecustomer\":0,\"agentcampaign\":null}]},\"total\":0,\"httpStatusToBeReturned\":200}"
}
}
]
}
The endpoint /orders/v1/ordersearch/ is working fine. But whenever I am trying to send a request to /encryption/v1/decrypt/ after sending a request to /orders/v1/ordersearch/ by doing a GET Request on http://localhost:56789/encryption/v1/decrypt/?q=9zMoRQYv8fPYMHokQ3Z83%2B8%2F%2FmGW5IbDjRTArpSvmW0%3D=&q=9zMoRQYv8fPYMHokQ3Z83%2B8%2F%2FmGW5IbDjRTArpSvmW0%3D&q=zryLbw62xF5dLFujFTFAyRVgyY3jQtA6gjJNOXb6N80%3D&q=5Qa6Rwor34cuaLKgjskeQ3G%2F0WnGArDHSl%2FJmuMfwxA%3D&q=5Qa6Rwor34cuaLKgjskeQ3G%2F0WnGArDHSl%2FJmuMfwxA%3D&q=NiJkjFQy2A6tySZAlxLKrVZtLQ2nbqm5WHbVrh9gMng%3D . It is giving me jetty.eofException as shown below:-
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 500 wiremock.org.mortbay.jetty.EofException</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /encryption/v1/decrypt/. Reason:
<pre> wiremock.org.mortbay.jetty.EofException</pre></p><h3>Caused by:</h3><pre>java.lang.RuntimeException: wiremock.org.mortbay.jetty.EofException
at com.github.tomakehurst.wiremock.jetty6.Jetty6HandlerDispatchingServlet.writeAndTranslateExceptions(Jetty6HandlerDispatchingServlet.java:134)
at com.github.tomakehurst.wiremock.jetty6.Jetty6HandlerDispatchingServlet.applyResponse(Jetty6HandlerDispatchingServlet.java:124)
at com.github.tomakehurst.wiremock.jetty6.Jetty6HandlerDispatchingServlet.service(Jetty6HandlerDispatchingServlet.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at wiremock.org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at wiremock.org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
at wiremock.org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at wiremock.org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at wiremock.org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at wiremock.org.mortbay.jetty.Server.handle(Server.java:326)
at wiremock.org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at wiremock.org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at wiremock.org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at wiremock.org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at wiremock.org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at wiremock.org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at com.github.tomakehurst.wiremock.jetty6.DelayableSocketConnector$1.run(DelayableSocketConnector.java:49)
at wiremock.org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: wiremock.org.mortbay.jetty.EofException
at wiremock.org.mortbay.jetty.HttpGenerator.completeHeader(HttpGenerator.java:273)
at wiremock.org.mortbay.jetty.HttpConnection.commitResponse(HttpConnection.java:632)
at wiremock.org.mortbay.jetty.HttpConnection$Output.flush(HttpConnection.java:1011)
at com.github.tomakehurst.wiremock.jetty6.Jetty6HandlerDispatchingServlet.writeAndTranslateExceptions(Jetty6HandlerDispatchingServlet.java:131)
... 17 more
</pre>
<h3>Caused by:</h3><pre>wiremock.org.mortbay.jetty.EofException
at wiremock.org.mortbay.jetty.HttpGenerator.completeHeader(HttpGenerator.java:273)
at wiremock.org.mortbay.jetty.HttpConnection.commitResponse(HttpConnection.java:632)
at wiremock.org.mortbay.jetty.HttpConnection$Output.flush(HttpConnection.java:1011)
at com.github.tomakehurst.wiremock.jetty6.Jetty6HandlerDispatchingServlet.writeAndTranslateExceptions(Jetty6HandlerDispatchingServlet.java:131)
at com.github.tomakehurst.wiremock.jetty6.Jetty6HandlerDispatchingServlet.applyResponse(Jetty6HandlerDispatchingServlet.java:124)
at com.github.tomakehurst.wiremock.jetty6.Jetty6HandlerDispatchingServlet.service(Jetty6HandlerDispatchingServlet.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at wiremock.org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at wiremock.org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
at wiremock.org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at wiremock.org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at wiremock.org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at wiremock.org.mortbay.jetty.Server.handle(Server.java:326)
at wiremock.org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at wiremock.org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at wiremock.org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at wiremock.org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at wiremock.org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at wiremock.org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at com.github.tomakehurst.wiremock.jetty6.DelayableSocketConnector$1.run(DelayableSocketConnector.java:49)
at wiremock.org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
</pre>
<hr /><i><small>Powered by Jetty://</small></i><br/>
<br/>
</body>
</html>
Can someone let me know if there is some misconfiguration on my side or it is some well know issue on Wiremock side?

There was an issue in my code. By mistake I set status to 0 in /encryption/v1/decrypt/.
ResponseDefinitionBuilder responseBuilder = aResponse().withStatus(0);
This one is also visible in the output of mappings:-
"mappings": [
{
"request": {
"urlPath": "/encryption/v1/decrypt/",
"method": "GET"
},
"response": {
"status": 0,
"body": "{\"message\":null,\"httpStatus\":0,\"status\":{\"httpStatusCode\":200,\"success\":true,\"errors\":[]},\"_metaData\":{\"urlParams\":{}},\"debugData\":null,\"data\":[\"01125851014\",\"01125851014\",\"debraj.manna#jabong.com\",\"03325853088\",\"03325853088\",\"debraj.manna#rediffmail.com\"],\"httpStatusToBeReturned\":200}"
}
},
....

Related

Implement different response with WireMock when no request(s) match

I'm trying to stub a RESTful API. One of the resources return the details when the resource is (indeed) found, or an HTTP 404 (Not Found) when, eventually, there is no resource for the given URL.
This is my simplified stub/mapping:
{
"mappings": [
{
"name": "Retrieve Items",
"request": {
"headers": {
"accept": {
"caseInsensitive": true,
"equalTo": "application/json"
}
},
"method": "GET",
"urlPathPattern": "/api/items/[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}"
},
"response": {
"bodyFileName": "items-api/responses/retrieve/{{ request.pathSegments.[2] }}.json",
"headers": {
"content-type": "application/json"
},
"status": 200
}
}
]
}
Then I have several JSON files (in /home/wiremock/__files/items-api/responses/retrieve/ to match the requests against — but I can't find a way to implement the HTTP 404 (Not Found) scenario:
{
"timestamp": {{ now }},
"status": 404,
"error": "Not Found",
"message": null,
"path": "{{ request.path }}"
}
With this config I get back (the expected, but not useful for my use case) response from WireMock that the file name uuid-sent-in-request.json is not found.
Is there a way to implement this behavior currently?
Tom's answer will work as well. I think the benefits to his solution are that they aren't tied to specific request URLs, but my suggestion is to have a specific mapping for the files that will match with their specific JSON files, and a catch-all mapping for un-matched files. By assigning the requests with JSON responses a higher priority, WireMock will check those first, and if the request does not match any of the values specified in that mapping, will then go on to check if the second mapping matches, and return a 404.
{
"mappings": [
{
"name": "Retrieve Items - Success",
"priority": 1, // arbitrary number lower than the second priority
"request": {
"headers": {
"accept": {
"caseInsensitive": true,
"equalTo": "application/json"
}
},
"method": "GET",
"urlPathPattern": "/api/items/(UUID1|UUID2|UUID3|UUID4)"
},
"response": {
"bodyFileName": "items-api/responses/retrieve/{{ request.pathSegments.[2] }}.json",
"headers": {
"content-type": "application/json"
},
"status": 200
}
},
{
"name": "Retrieve Items - 404 Not Found",
"priority": 5, // arbitrary number that is higher than 1
"request": {
"headers": {
"accept": {
"caseInsensitive": true,
"equalTo": "application/json"
}
},
"method": "GET",
"urlPathPattern": "/api/items/[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}"
},
"response": {
"status": 404
}
}
]
}
Currently you would need to write a ResponseDefinitionTransformer to get the behaviour you're looking for.
It would need to check whether the ResponseDefinition passed in the parameter required a file, then if so check whether the file exists by doing something like:
try {
fileSource.getBinaryFileNamed(bodyFileName).readContents();
} catch (FileNotFoundException e) {
return WireMock.notFound().withBody("custom body");
}
// Otherwise return the unmodified response definition

Wiremock how to map a 302 response in JSON for standalone run

In wiremock, if you are using it for testing, you can programately return 302 using temporaryRedirect(String destination) with a detination path
stubFor(post(urlEqualTo("/firsturl"))
.willReturn(temporaryRedirect("https://somehost:8080/test/")))
My question is: How can I do the same in standalone running mode, using json mapping file
{
"request": {
"method": "POST",
"url": "/api/test"
},
"response": {
"status": 302,
????? <- how to return the path?
}
}
Was not able to find anything about this.
If you want to redirect to a separate url, you can use the WireMock's proxying functionality.
It would look something like...
{
"request": {
"method": "POST",
"url": "/api/test"
},
"response": {
"status": 302,
"proxyBaseUrl": "https://somehost:8080/test/"
}
}
temporaryRedirect("https://somehost:8080/test/") is a wrapper around aResponse().withStatus(302).withHeader(LOCATION, "https://somehost:8080/test/")
In json configuration it will be:
{
"request": {
"method": "POST",
"url": "/api/test"
},
"response": {
"status": 302,
"headers": {
"Location": "https://somehost:8080/test/"
}
}
}

Sharepoint Rest API - Apply filter on expanded fields - Status 400

I am using Sharepoint rest API to get specific files in a group of folders. For this, I am applying filter on the expanded field. The problem is when I apply filter, it says the "Field or property does not exist"
I've tried to get the data without applying filter and it's coming correctly. Also, I am able to apply filter on the fields which are not under the expand parameter.
Below code is working in postman:
https://sp.foo.net/sites/spdsdfrn/_api/web/GetFolderByServerRelativeUrl('Shared Documents/abc/2019')/Folders?$expand=Files&$select=Files/Name&$filter=Files/Name eq 'abc.xlsx'
Below is the relevant part of the output:
{
"d": {
"results": [
{
"__metadata": {
"id": "https://sp.foo.net/sites/spdsdfrn/_api/web/GetFolderByServerRelativeUrl('Shared Documents/abc/2019/folder1')",
"uri": "https://sp.foo.net/sites/spdsdfrn/_api/web/GetFolderByServerRelativeUrl('Shared Documents/abc/2019/folder1')",
"type": "SP.Folder"
},
"Files": {
"results": [
{
"__metadata": {
"id": "https://sp.foo.net/sites/spdsdfrn/_api/web/GetFolderByServerRelativeUrl('Shared Documents/abc/2019/folder1/abc.xlsx')",
"uri": "https://sp.foo.net/sites/spdsdfrn/_api/web/GetFolderByServerRelativeUrl('Shared Documents/abc/2019/folder1/abc.xlsx')",
"type": "SP.File"
},
"Name": "abc.xlsx"
},
{
"__metadata": {
"id": "https://sp.foo.net/sites/spdsdfrn/_api/web/GetFolderByServerRelativeUrl('Shared Documents/abc/2019/folder1/def.xlsx')",
"uri": "https://sp.foo.net/sites/spdsdfrn/_api/web/GetFolderByServerRelativeUrl('Shared Documents/abc/2019/folder1/def.xlsx')",
"type": "SP.File"
},
"Name": "def.xlsx"
}
]
}
},
.........
.........
..........
Below code is not working in postman:
https://sp.foo.net/sites/spdsdfrn/_api/web/GetFolderByServerRelativeUrl('Shared Documents/abc/2019')/Folders?$expand=Files&$select=Files/Name&$filter=Files/Name eq 'abc.xlsx'
Below is the error output I am getting with status code 400 (bad request):
{
"error": {
"code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
"message": {
"lang": "en-US",
"value": "Field or property \"Name\" does not exist."
}
}
}
I've seen many solutions on the internet and they suggest that it should work in this way. Also, I've seen to check the internal names as they might differ but it's same "Name" in this case.
Is it some bug or I am missing something?
This looks like a typo:
"Field or property \"Names\" does not exist."
As your URL references "Name" not "Names".
Your second URL does not have the file type (.xlsx)
&$filter=Files/Name eq 'abc'
Otherwise...
Your URL includes "/folder". This returns a list of folders. Are you looking for a file in a particular folder, or all files by that name in any folder?
This will return a file in a particular folder:
https://sp.foo.net/sites/spdsdfrn/_api/web/GetFolderByServerRelativeUrl('Shared Documents/abc/2019')/files?$select=Name&$filter=Name eq 'abc.xlsx'
Technically speaking... It's a "server relative", not "site relative" URL. But starting with the library name seems to work.
https://sp.foo.net/sites/spdsdfrn/_api/web/GetFolderByServerRelativeUrl('Shared Documents/abc/2019')/Folders
probably should be:
https://sp.foo.net/sites/spdsdfrn/_api/web/GetFolderByServerRelativeUrl('/sites/spdsdfrn/Shared Documents/abc/2019')/Folders
You can use GetItems method in combination with setting FolderServerRelativeUrl property and Scope.
Example code:
<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var fileName="abc.xlsx";
var libraryTitle="Documents";
var folderRelativeUrl="Shared Documents/abc/2019";
var viewXml = "<View Scope='RecursiveAll'><Query><Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='File'>"+fileName+"</Value></Eq></Where></Query></View>";
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('"+libraryTitle+"')/getitems?$select=*,FileDirRef,FileRef";
var query = {
'query' : {
'__metadata': { 'type': 'SP.CamlQuery' },
'ViewXml' : viewXml,
'FolderServerRelativeUrl': folderRelativeUrl
}
};
$.ajax({
url: url,
method: "POST",
data: JSON.stringify(query),
headers: {
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"Accept": "application/json; odata=verbose",
"content-type": "application/json; odata=verbose"
},
success: function (data) {
alert(JSON.stringify(data.d.results));
},
error: function (err) {
alert(JSON.stringify(err));
}
});
});
</script>
Or we can use the REST API below.
/_api/web/lists/getbytitle('Documents')/items?$select=File&$expand=File&$filter=FileLeafRef eq 'abc.xlsx'

Fetching multiple event details in Office 365

I need to fetch information related to eventId from office 365 for multiple events.
Is there a way I can get that info in a single REST call?
I want specific events only (based on eventId's only)
A batch request may be what you are looking for.
See json Batching Documentation for more information
Keep in mind that batching is currently limited to 20 requests per message (known issues)
Example:
You will need to send a POST Message to the batch endpoint
https://graph.microsoft.com/v1.0/$batch
inside the body you will need to include your requests:
Note: do not include the server url (https://graph.microsoft.com/v1.0/) in the url property or the request will fail with "BadRequest - Invalid request Uri".
Request-Body:
{
"requests": [
{
"id": "1",
"method": "GET",
"url": "/me/calendarview?startdatetime=2018-03-01T18:31:34.206Z&enddatetime=2018-03-12T18:31:34.206Z"
},
{
"id": "2",
"method": "GET",
"url": "/me/events/{someEventId}"
},
]
}
When the server has processed all requests an response array containing the results will be sent back:
Server-Response:
{
"responses": [
{
"id": "2",
"status": 200,
"headers": {
"OData-Version": "4.0",
"Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8",
"ETag": "W/\"Z+ICSvkiAfZX7XWQAZ6IH==\""
},
"body": {
// the event object
}
},
{
"id": "1",
"status": 200,
"headers": {
"OData-Version": "4.0",
"Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
},
"body": {
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('aUserID')/calendarView",
"value": [
// list of found event-objects
]
}
}
]
}

Unable to create a form with multiple FormFields using REST API for Oracle Eloqua Marketing Cloud Service?

I am testing the REST API for Oracle Eloqua Marketing Cloud Service method for creating forms using POSTMAN.
REST API link.
When I give single form field, form is getting created. this is my request:
POST /assets/form
Content-Type: application/json
But when I try to create form with multiple form fields like here:
Request body: {
"type": "Form",
"createdAt": "1510563258",
"createdBy": "9",
"folderId": "7",
"name": "Form with 3 fields_de-DE1254",
"updatedAt": "1510563258",
"elements": [
{
"style": "{\"fieldSize\":\"large\",\"labelPosition\":\"top\"}",
"type": "FormField",
"name": "Æddrèëss 2",
"dataType": "text",
"displayType": "text",
"htmlName": "address2",
"useGlobalSubscriptionStatus": "False",
"validations": []
},
{
"style": "{\"fieldSize\":\"large\",\"labelPosition\":\"top\"}",
"type": "FormField",
"name": "Æddrèëss 3",
"dataType": "text",
"displayType": "text",
"htmlName": "address3",
"useGlobalSubscriptionStatus": "False",
"validations": []
}
]
}
I get error:
Status : 500 InternalServerError
<html>
<head>
<title>Internal Server Error</title>
</head>
<body>
<h1>
Internal Server Error
</h1>
<div>
There was an internal server error.
</div>
<div>
The error has been logged with log identifier
<b>115451307</b>.
</div>
<div>
Please provide this log identifier to technical support.
</div>
</body>
</html>
Please can someone help me with this? Also what is is this log identifier and where can I find it?
I just had this and got the solution from support. You need to put in a unique and negative integer for the field ids. After doing this, you can send in an array of form fields and they will all get processed in one call. The response will contain the newly generated ids, if successful.
Here's the modified snippet:
Request body: {
"type": "Form",
"createdAt": "1510563258",
"createdBy": "9",
"folderId": "7",
"name": "Form with 3 fields_de-DE1254",
"updatedAt": "1510563258",
"elements": [
{
"id": "-1",
"style": "{\"fieldSize\":\"large\",\"labelPosition\":\"top\"}",
"type": "FormField",
"name": "Æddrèëss 2",
"dataType": "text",
"displayType": "text",
"htmlName": "address2",
"useGlobalSubscriptionStatus": "False",
"validations": []
},
{
"id": "-2",
"style": "{\"fieldSize\":\"large\",\"labelPosition\":\"top\"}",
"type": "FormField",
"name": "Æddrèëss 3",
"dataType": "text",
"displayType": "text",
"htmlName": "address3",
"useGlobalSubscriptionStatus": "False",
"validations": []
}
]
}