Comments on: REST-ASSURED – HOW TO POST A JSON REQUEST https://testguild.com/rest-assured-how-to-post-a-json-request/ Wed, 26 Jan 2022 10:15:21 +0000 hourly 1 By: Aminul https://testguild.com/rest-assured-how-to-post-a-json-request/#comment-234085 Fri, 12 Aug 2016 18:25:49 +0000 https://testguild.com/?p=1866#comment-234085 Add your file in the resource folder and call it using below code ..
URL file = Resources.getResource(“yourfile.json”);
String myJson = Resources.toString(file, Charsets.UTF_8);

Response responsedata = given().header(“Authorization”, AuthrztionValue)
.header(“X-App-Client-Id”, XappClintIDvalue).contentType(“application/vnd.api+json”).body(myJson).with()

.when().post(your URL)

]]>
By: Snigdha Kasimahanthi https://testguild.com/rest-assured-how-to-post-a-json-request/#comment-232088 Wed, 03 Aug 2016 21:26:52 +0000 https://testguild.com/?p=1866#comment-232088 Hi,
With respect to the questions posted by Balveer and QA Tester,
you may want to create a class with all the required fields, instatiate it and then pass the object in the body.
Say from Balveer’s payload above, userName, accountReferenceID, updatedBy etc will constitute the fields, include getters and setters in the class for the fields, instantiate the class with an Object say payload_obj and pass it as an Object within the body.

body(payload_obj).

]]>
By: balveer https://testguild.com/rest-assured-how-to-post-a-json-request/#comment-165752 Tue, 11 Aug 2015 14:56:19 +0000 https://testguild.com/?p=1866#comment-165752 i have a payload similar to

{
“createdBy”: “exchange@sdp.com”,
“createdOn”: “2015-08-07T16:47:27.527+05:30”,
“id”: 500050,
“updatedBy”: “exchange@sdp.com”,
“updatedOn”: “2015-08-11T12:35:29.606+05:30”,
“accountContexts”: [
“EXCHANGE”
],
“accountReferenceId”: “C00000003”,
“billPayer”: false,
“changePassword”: false,
“correspondenceAddress”: {
“createdBy”: “exchange@sdp.com”,
“createdOn”: “2015-08-07T16:47:27.528+05:30”,
“id”: 500050,
“updatedBy”: “exchange@sdp.com”,
“updatedOn”: “2015-08-07T16:47:27.528+05:30”,
“city”: “bangalore”,
“country”: “india”,
“postalCode”: “23167”,
“state”: “KA”,
“street”: “Sarjapur”
},
“emailAddress”: “operator111@cim.com”,
“name”: “operator111@cim.com”,
“parentInfo”: {
“createdBy”: “superadmin”,
“createdOn”: “2015-05-13T12:41:23.433+05:30”,
“id”: 1011,
“updatedBy”: “superadmin”,
“updatedOn”: “2015-05-13T12:41:23.433+05:30”,
“accountContexts”: [
“EXCHANGE”
],
“accountReferenceId”: “A1011”,
“billPayer”: true,
“emailAddress”: “exchange@sdp.com”,
“name”: “EXCHANGE”,
“phoneNumber”: “9181818181”,
“representative”: false,
“state”: “ACTIVE”,
“typeId”: 1001,
“typeName”: “EXCHANGE_ACCOUNT_TYPE”,
“userName”: “exchange@sdp.com”
},
“phoneNumber”: “234567”,
“representative”: false,
“state”: “OBSOLETE”,
“type”: {
“createdBy”: “exchange@sdp.com”,
“createdOn”: “2015-08-07T12:53:04.048+05:30”,
“id”: 500000,
“updatedBy”: “exchange@sdp.com”,
“updatedOn”: “2015-08-07T12:53:04.048+05:30”,
“name”: “CIM_USERS”,
“ownerName”: “EXCHANGE”
},
“useExternalAuthentication”: false,
“userName”: “operator111@cim.com”,
“password”: “Cisco_123”
}

could you please help me how to send above payload as post request.

]]>
By: s https://testguild.com/rest-assured-how-to-post-a-json-request/#comment-148194 Sun, 22 Feb 2015 11:32:37 +0000 https://testguild.com/?p=1866#comment-148194 Hi there,

How to add a tokenize header with a post request

]]>
By: QAtester https://testguild.com/rest-assured-how-to-post-a-json-request/#comment-126121 Wed, 03 Sep 2014 04:56:52 +0000 https://testguild.com/?p=1866#comment-126121 Hi Joe
Thanks for the great explanation

I do have some questions though!
How do you got your myJSON string?
My Json code is huge and am unware how to format it to string
Here goes my JSON Code:

{“GuestOrder”:{“GuestOrderNumber”:”999456789″,”GuestFirstName”:”Abraham”,”GuestLastName”:”Doe”,”OriginatorCode”:”OMS”,”FulfillmentLocation”:”3303″,”EventDateTime”:”2012-12-10T11:10:20″,”MessageDateTime”:”2012-12-10T11:10:22″,”PriorityCode”:”storepickup”,”FulfillByDateTime”:”2012-12-10T11:11:22″,”StoreTransferOrderList”:{“StoreTransferOrder”:”101220009100″,”StoreTransferShipmentList”:{“StoreTransferShipment”:”8822700100″,”ReleaseNumber”:”98591069710444″,”ContainerList”:{“Container”:[{“ContainerNumber”:”9876544001″,”TrackingNumber”:”1Z123AB45CD6789001″,”ItemList”:{“Item”:{“TCIN”:”991238822″,”LineNumber”:”1″,”ShipmentLineNumber”:”1″,”Dept”:”123″,”Class”:”12″,”Item”:”1234″,”RequestedQTY”:”12″,”Notes”:”First Container First Item “}}},{“ContainerNumber”:”9876555200″,”TrackingNumber”:”1ZA819CD412L569200″,”ItemList”:{“Item”:[{“TCIN”:”119998888″,”LineNumber”:”2″,”ShipmentLineNumber”:”2″,”Dept”:”123″,”Class”:”12″,”Item”:”1234″,”RequestedQTY”:”12″,”Notes”:”second Container First Item “},{“TCIN”:”229998888″,”LineNumber”:”1″,”ShipmentLineNumber”:”3″,”Dept”:”9″,”Class”:”12″,”Item”:”99″,”RequestedQTY”:”12″,”Notes”:”second Container second Item “}]}}]}}}}}

]]>
By: [BLOCKED BY STBV] Testing Bits – 4/20/14 – 4/26/14 | Testing Curator Blog https://testguild.com/rest-assured-how-to-post-a-json-request/#comment-104907 Sun, 27 Apr 2014 15:33:52 +0000 https://testguild.com/?p=1866#comment-104907 […] REST-Assured – How to Post a JSPON Request – Joe Colantonio – https://testguild.com/2014/04/24/rest-assured-how-to-post-a-json-request/ […]

]]>