Calling API in invoke code

Hi All,

I need to pass API body as following for post API in invoke activity.Body will be coming from the excel .please help

{
“attendeeEmailIds”: [
{
“emailId”: “aa@gmail.com”,
“type”: “required”
}
],
“body”: “test”,
“durationInMin”: 10,
“location”: “string”,
“meetingDateAndTimeInUTC”: “2022-02-27T07:11:28.810Z”,
“platformId”: “teams”,
“subject”: “test”
}

Hi @tharani.natarajan
U can either use the json format in text file and replace the required data from excel using string manipulation

then using string argument, pass it as input parameter to invoke code activity

Regards

Nived N

Happy Automation

Thanks for the response Nived,i have given it as string only but when i run the code i get the following error

RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> RemoteException wrapping System.ArgumentException: The format of value ‘{
“attendeeEmailIds”: [
{
“emailId”: “aaa@bbb.com”,
“type”: “required”
}
],
“body”: “test”,
“durationInMin”: 10,
“location”: “string”,
“meetingDateAndTimeInUTC”: “2022-02-27T07:11:28.810Z”,
“platformId”: “teams”,
“subject”: “test”
}’ is invalid.
at System.Net.Http.Headers.ContentDispositionHeaderValue.EncodeAndQuoteMime(String input)
at System.Net.Http.Headers.ContentDispositionHeaderValue.SetName(String parameter, String value)
at System.Net.Http.MultipartFormDataContent.AddInternal(HttpContent content, String name, String fileName)
at System.Net.Http.MultipartFormDataContent.Add(HttpContent content, String name)
at UiPathCodeRunner_e8a867d4dd7b4334814af5cce991d0d9.Run(String newBody, String Argument1)
— End of inner exception stack trace —
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object providedArgs, ParameterModifier modifiers, CultureInfo culture, String namedParams)
at UiPath.Activities.System.Utilities.InvokeCode.CompilerRunner.Run(Object args)
at UiPath.Activities.System.Utilities.InvokeCode.NetCodeInvoker.Run(String userCode, List1 inArgs, IEnumerable1 imps, Object args)
at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Hi @tharani.natarajan
do did convert it to json format in invoke code while sending request

No …The above body is string …and i am passing directly into invoke code.Can you please help me with sample process