Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Sending request as multipart/form-data

shivmano
Regular Contributor III
Regular Contributor III

Team, I need to send a Request Body for account creation as multipart/form-data to an application as it accepts only data in this format. I have configured the contenttype accordingly but it does not seem to work. Below is the CREATEACCOUNTJSON and Postman request. Please can you advise how can I successfully send this multipart request? When I am using the below specified JSON, I am getting the error - {"status":"FAIL","code":470,"errors":"Multipart message request is invalid. ParameterRequest body content type should be 'application/json'."}, cookies:[useractivity_cookie_mingle=1681993849; secure; httponly; path=/; domain=inforcloudsuite.com; SameSite=Lax], statusCode:400]

But if I send the request as application/json, then it says unsupported Media Format.  ("errormessage":"Requested Media type is : application/json, OutboundJaxrsResponse{status=415, reason=Unsupported Media Type)

Here is the JSON and the postman call, ( ON postman both the parameters are being send as form-data)

{
"accountIdPath": "accountName",
"call": [
{
"name": "call1",
"connection": "userAuth",
"url": "***************",
"httpMethod": "POST",
"httpParams": "{\"ParameterRequest\": [{}],\"MessagePayload\": [{\"AddUser\": {}}]}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "multipart/form-data",
"successResponses": {
"statusCode": [
200,
201,
202
]
},
"unsuccessResponses": {
"statusCode": [
400,
401,
403,
404,
408,
412,
500
]
}
}
]
}

shivmano_0-1681996746034.png

 

 

15 REPLIES 15

SB
Saviynt Employee
Saviynt Employee

Can you share the postman export of this call.


Regards,
Sahil

shivmano
Regular Contributor III
Regular Contributor III

@SB attached is the postman export 

shivmano
Regular Contributor III
Regular Contributor III

@SB / Team - Any advise on this please ? I am still having issue sending data as form-data from Saviynt 

SB
Saviynt Employee
Saviynt Employee

Can you try with the below format and see if it works

"httpContentType": "form-data"  OR

"httpContentType": "formdata"


Regards,
Sahil

shivmano
Regular Contributor III
Regular Contributor III

Thank you @SB . I am now getting a 400 Bad request error and a bad constructor error while trying with either of the above httpcontenttype. Here is the JSON payload. Please can you advise if anything is wrong here?

{
"accountIdPath": "accountName",
"call": [
{
"name": "call1",
"connection": "userAuth",
"url": "https://**************/multipartMessage",
"httpMethod": "POST",
"httpParams": "{\"ParameterRequest\": [{\"documentName\": \"Saviynt_AddUser_JSON\",\"messageId\": \"2023-04-20 11:40:53.0\",\"fromLogicalId\": \"lid://abc.123.saviynt_iam_api\",\"toLogicalId\": \"lid://abc.123.saviynt_iam_api\",\"encoding\": \"NONE\",\"characterSet\": \"UTF-8\",\"accountingEntity\": \"*\",\"documentId\": \"2023-04-20 11:40:53.0\",\"source\": \"Saviynt\"}],\"MessagePayload\": [{\"AddUser\": [{\"FirstName\": \"abc\",\"LastName\": \"xyz\",\"email\": \"abc.xyz@domain.com\",\"role\": \"test-role\",\"employeeId\": \"12345\"}]}]}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "form-data",
"successResponses": {
"statusCode": [
200,
201,
202
]
},
"unsuccessResponses": {
"statusCode": [
400,
401,
403,
404,
408,
412,
500
]
}
}
]
}

 

Error:

2023-04-25 06:51:59,260 [quartzScheduler_Worker-4] DEBUG rest.RestProvisioningService - Exception while iterating Http Map instance
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.lang.String(java.util.ArrayList)

<td>HTTP ERROR: 400 Bad Request
<p>Problem accessing /*************/multipartMessage
<pre id="message">Bad Request</pre>
</p>
</td>
</tr>
</table>
<hr />
<div id="ef">Infor ION Grid - Copyright © 2009-2023 Infor.</body>
</html>

shivmano
Regular Contributor III
Regular Contributor III

I figured that the square brackets were giving the json constructor error. I corrected that and send the payload with httpcontenttype as both 'form-data' and 'formdata' but still get the 400 bad request error

shivmano
Regular Contributor III
Regular Contributor III

@SB Here is the payload I am sending and getting the 400 response 

{
"accountIdPath": "accountName",
"call": [
{
"name": "call1",
"connection": "userAuth",
"url": "https://**************/multipartMessage",
"httpMethod": "POST",
"httpParams": "{\"ParameterRequest\": {\"documentName\": \"Saviynt_AddUser_JSON\",\"messageId\": \"2023-04-20 11:40:53.0\",\"fromLogicalId\": \"lid://abc.123.saviynt_iam_api\",\"toLogicalId\": \"lid://abc.123.saviynt_iam_api\",\"encoding\": \"NONE\",\"characterSet\": \"UTF-8\",\"accountingEntity\": \"*\",\"documentId\": \"2023-04-20 11:40:53.0\",\"source\": \"Saviynt\"},\"MessagePayload\": {\"AddUser\": {\"FirstName\": \"abc\",\"LastName\": \"xyz\",\"email\": \"abc.xyz@domain.com\",\"role\": \"test-role\",\"employeeId\": \"12345\"}}}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "formdata",
"successResponses": {
"statusCode": [
200,
201,
202
]
},
"unsuccessResponses": {
"statusCode": [
400,
401,
403,
404,
408,
412,
500
]
}
}
]
}

 

</td>
<td>HTTP ERROR: 400 Bad Request
<p>Problem accessing /***********/multipartMessage
<pre id="message">Bad Request</pre>
</p>
</td>
</tr>
</table>
<hr />

shivmano
Regular Contributor III
Regular Contributor III

I am also observing that the data we are sending as 'multipart/form-data' is somehow getting received as 'Plain/Text' at the endpoint. Is there a best way to handle this on Saviynt ?

SB
Saviynt Employee
Saviynt Employee

Can you check for the logs for the string (from Calling Webservice Url to Got Webservice API Response) and share. 


Regards,
Sahil

shivmano
Regular Contributor III
Regular Contributor III

@SB I have attached 2 log files. One while trying with httpcontenttype - 'multipart/form-data' and other with httpcontenttype - 'formdata'. thank you

shivmano
Regular Contributor III
Regular Contributor III

@SB can you please let me know if there is anything else that can be done to send data as 'form-data' ? I had attached the logs as requested

SB
Saviynt Employee
Saviynt Employee

Can you update httpHeaders in JSON as below and then try with form-data.

"httpHeaders": {
"Authorization": "${access_token}",
"Accept": "application/json",
"Content-Type": "application/octet-stream"
}


Regards,
Sahil

shivmano
Regular Contributor III
Regular Contributor III

@SB , thanks for your response. Unfortunately it still does not work. It gives the ' Unsupported Media Type,' error in the Webservice API Response. 

{
"accountIdPath": "accountName",
"call": [
{
"name": "call1",
"connection": "userAuth",
"url": "",
"httpMethod": "POST",
"httpParams": "{}",
"httpHeaders": {
"Authorization": "${access_token}",
"Accept": "application/json",
"Content-Type": "application/octet-stream"
},
"httpContentType": "form-data",
"successResponses": {
"statusCode": [
200,
201,
202
]
},
"unsuccessResponses": {
"statusCode": [
400,
401,
403,
404,
408,
412,
500
]
}
}
]
}

shivmano
Regular Contributor III
Regular Contributor III

Team, it is observed that when we send the data as multipart/form-data from Saviynt, at the endpoint, the multipart content types are somehow being received as 'text/plain'. Is there any way to control it ? adding the content type under headers does not help it 

 

shivmano_1-1683545630571.png

 

SB
Saviynt Employee
Saviynt Employee

I wanted to check if this is still an issue or was it resolved.


Regards,
Sahil