How to send variable in Json body to http request activity

Hi, I am a new to UiPath . I want to send variable (String1) in json body to Https request activity.
I have tried few ways but nothing seems to be working.

I am trying to send below json which I have assigned in Variable “String1”,

“{‘Service’:{‘ServiceHeader’:{‘RequestorID’:‘RPA’,‘RequestID’:‘1918***1’},‘ServiceBody’:{‘CallReason’:‘D11’,‘CallRequest’:{‘Action’:‘UpdateVcatsRPAStatus’,‘Body’:{‘EntityName’:‘de1p2-prgpe1-2971059e001’,‘EntityStatus’:‘Processing2’,‘TransactionID’:‘b8e111b6a-4651-4f00-a788-7de1d376756a’,‘RPABOTID’:‘31443576’}}}}}”.

Studio doesn’t seem to give any error for the above format. Please find the below attached encountred error.

image

Please also find the attached header that I am sending along with Json body.

image

It would be great if I could get an example on this
Thanks

Hi Shekharhimanshu627 and welcome.

Ok, so firstly, your son is not correct. You should use double quotes (") instead of single (') in your properties and values. Like this:

{
    "name": "Shekharhimanshu627",
    "post":{
               "url": "https://forum.uipath.com/t/how-to-send-variable-in-json-body-to-http-request-activity/749332"
     }
}

With that out of the way, to use your variable, you can simply use it in the body property of the Http Request activity:
image

Hi @lucas.stern, Thank you for the reply. I am getting compiler error while pasting json data in “body” properties of “http request” activity.
Please find the below data that i am trying to pass inside body properties.

Regards,
Himanshu

Quotes inside a string needs to be escaped with an additional one like

"{""PropA"": 123,""PropB"":""ABC""}"

@shekharhimanshu627

"{""Service"":{""ServiceHeader"":{""RequestorID"":""RPA"",""RequestID"":""1918***1""},""ServiceBody"":{""CallReason"":""D11"",""CallRequest"":{""Action"":""UpdateVcatsRPAStatus"",""Body"":{""EntityName"":""de1p2-prgpe1-2971059e001"",""EntityStatus"":""Processing2"",""TransactionID"":""b8e111b6a-4651-4f00-a788-7de1d376756a"",""RPABOTID"":""31443576""}}}}}"

@shekharhimanshu627

"{""Service"":{""ServiceHeader"":{""RequestorID"":""RPA"",""RequestID"":""1918***1""},""ServiceBody"":{""CallReason"":""D11"",""CallRequest"":{""Action"":""UpdateVcatsRPAStatus"",""Body"":{""EntityName"":""de1p2-prgpe1-2971059e001"",""EntityStatus"":""Processing2"",""TransactionID"":""b8e111b6a-4651-4f00-a788-7de1d376756a"",""RPABOTID"":""31443576""}}}}}"

Hi @pravallikapaluri , I think its working fine. Thanks for your support. Now I am getting different error while using Post Method.

System.Net.WebException: The SSL connection could not be established, see inner exception. —> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. —> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception)
at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions)
at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte reAuthenticationData, Boolean isApm)
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
— End of inner exception stack trace —
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request)
at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.AuthenticationHelper.SendWithAuthAsync(HttpRequestMessage request, Uri authUri, Boolean async, ICredentials credentials, Boolean preAuthenticate, Boolean isProxyAuth, Boolean doRequestAuth, HttpConnectionPool pool, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.DecompressionHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at System.Net.HttpWebRequest.SendRequest(Boolean async)
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
— End of inner exception stack trace —
at UiPath.Web.Activities.HttpClient.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

@shekharhimanshu627
Sorry to say
I dont have that much Plenty of idea regarding this.
But I think we got Solution for this topic created.
Close this topic and raise another question to solve the issue and some others help . It will definitely help others also to search a topic

Hope it helps!!

This new error looks like a network problem, maybe you dont have route between your machine and the uri??

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.