Quantcast
Channel: LoadRunner Practitioners Forum topics
Viewing all articles
Browse latest Browse all 3978

Substituting part of request body json with dynamically created string

$
0
0

Hi,

I am facing a strage problem in substituting a string dynamically created by substituting parameter values and sending as part of json body. When I directly send the request with the string the request passes and if I copy the same string to a character pointer and pass the same to the json, the request fails with a http 400 error.

Below is the string I send via char pointer.

char *bodystring="{\\\"ActualScannedBarcodeValue\\\":\\\"XB306247306GB\\\",\\\"Barcode\\\":\\\"XB306247306GB\\\",\\\"barcodeType\\\":\\\"NORMAL\\\",\\\"TimeStamp\\\":\\\"/Date(1481731291688)/\\\",\\\"IsSignatureRequired\\\":false,\\\"Latitude\\\":0.0,\\\"Longitude\\\":0.0,\\\"PackageType\\\":0,\\\"IsScanned\\\":true,\\\"StatusId\\\":1,\\\"IsReturnToSender\\\":false,\\\"IsNeighbourSignatureRequired\\\":false,\\\"IsManualEntry\\\":false,\\\"isAdditionalInfoRequired\\\":false,\\\"isPrepopulated\\\":false,\\\"IsIdentityProofRequired\\\":false,\\\"IsForwardToRecipient\\\":false,\\\"IsForwardToNrc\\\":true}";

converting the string to a parameter

lr_save_string(bodystring,"p_Body"); and attach to the body part as a parameter.

If I send above string directly in the json the request passes, as below

{\"ActualScannedBarcodeValue\":\"XB306247306GB\",\"Barcode\":\"XB306247306GB\",\"barcodeType\":\"NORMAL\",\"TimeStamp\":\"/Date(1481731291688)/\",\"IsSignatureRequired\":false,\"Latitude\":0.0,\"Longitude\":0.0,\"PackageType\":0,\"IsScanned\":true,\"StatusId\":1,\"IsReturnToSender\":false,\"IsNeighbourSignatureRequired\":false,\"IsManualEntry\":false,\"isAdditionalInfoRequired\":false,\"isPrepopulated\":false,\"IsIdentityProofRequired\":false,\"IsForwardToRecipient\":false,\"IsForwardToNrc\":true}

The whole body part is give below.

"Body={\"TimeStamp\":\"/Date({h_Date})/\",\"PackageList\":[{\"ActualScannedBarcodeValue\":\"XB306247306GB\",\"Barcode\":\"XB306247306GB\",\"barcodeType\":\"NORMAL\",\"TimeStamp\":\"/Date(1481731291688)/\",\"IsSignatureRequired\":false,\"Latitude\":0.0,\"Longitude\":0.0,\"PackageType\":0,\"IsScanned\":true,\"StatusId\":1,\"IsReturnToSender\":false,\"IsNeighbourSignatureRequired\":false,\"IsManualEntry\":false,\"isAdditionalInfoRequired\":false,\"isPrepopulated\":false,\"IsIdentityProofRequired\":false,\"IsForwardToRecipient\":false,\"IsForwardToNrc\":true}],\"ManifestId\":0,\"ModuleId\":1,\"ProcessId\":{p_ProcessId},\"LocationId\":{p_LocationId},\"SubProcessId\":{p_SubProcessId},\"BusinessEntityID\":1,\"UserID\":{c_X-PMC-CredentialId},\"MainAltitude\":0.0,\"MainLatitude\":0.0,\"MainLongitude\":0.0}"

Please let me know how I can substitute the body part by saving the same to a char pointer and use as a parameter

 

 

 


Viewing all articles
Browse latest Browse all 3978

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>