For a deeper look into our World Check One API, look into:

Overview |  Quickstart |  Documentation |  Downloads

question

surinder.kumar avatar image
1 1 4 4

401 error when custom fields are passed during Sync Case Screening request

Hi Team,

We have .net code to make sync case creation request, which keep on failing when we add custom field in the post data and we are getting 401 error bad request, because of new requirement we have added custom field 'PartyID' under group setting for one of the group.

Post Data look something like that:

{"secondaryFields":[],"customFields":[{"typeId":"PartyID","value":"xxxxxxxxx"}],"providerTypes":["WATCHLIST"],"entityType":"ORGANISATION","groupId":"xxxxx-xxxx-xxxx-xxxx-eXXXXXX","caseId":"","name":"ABC Logistics Trust2"}

AND .net code is: issue is that without custom field case created without any issue and as soon as custom field added system throws exception.

public string WC1SyncCaseScreeningRequest(oBJECT requestObj, XmlElement request, string calledBy, string quoteId, string historyId, string partyType)
{ DateTime dateValue = DateTime.UtcNow; // get the datetime NOW GMT
string wcServiceResponse = string.Empty;
string date = dateValue.ToString("R"); // WC1 header requires GMT datetime stamp
string requestendpoint = "https://" + GateWayHost + GateWayUrl + "cases/screeningRequest"; string postData =string.Empty;
postData = CreatePostData(OfacWCScreener.XmlEscape(string.Concat(requestObj.FirstName, " ", requestObj.LastName)).Trim(), requestObj.NameType, requestObj.PartyID); string str = string.Empty;
try
{
string msg = postData;
UTF8Encoding encoding = new UTF8Encoding();
byte[] byte1 = encoding.GetBytes(postData);
string dataToSign = "(request-target): post " + GateWayUrl + "cases/screeningRequest" + "\n" +
"host: " + GateWayHost + "\n" +
"date: " + date + "\n" +
"content-type: " + "application/json" + "\n" +
"content-length: " + byte1.Length + "\n" +
msg; string hmac = generateAuthHeader(dataToSign, APISecret); string authorisation = "Signature keyId=\"" + APIKey + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date content-type content-length\",signature=\"" + hmac + "\"";
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(requestendpoint);
WebReq.Method = "POST";
WebReq.Headers.Add("Authorization", authorisation);
WebReq.Headers.Add("Cache-Control", "no-cache");
WebReq.ContentLength = msg.Length;
WebReq.Date = dateValue;
WebReq.ContentType = "application/json";
WebReq.ContentLength = byte1.Length;

using (Stream newStream = WebReq.GetRequestStream())
{
newStream.Write(byte1, 0, byte1.Length);
using (HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse()) Your quick response will be appericiated. Regards, Surinder Kumar

world-checkworld-check-oneerror-401
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Prabhjyot avatar image
4.5k 4 7 8

@surinder.kumar,

Thank you for the query.

As per the information provided in the above query, you should ideally get Error 400 : Bad request and not Error 401.

Can you please update the custom field information with the required 'typeId' information available in the case template instead of 'Party ID' and try again?

For example - If the case template provides the custom field values as below -

"customFields": [{
"typeId": "0a3687d0-6334-14a5-98e4-2dd200000f22",
"fieldValueType": "TEXT",
"regExp": null,
"fieldRequired": false,
"label": "Party ID"
}],

The custom field information to be passed in the request body would be -

{
"secondaryFields": [],
"customFields": [{
"typeId": "0a3687d0-6334-14a5-98e4-2dd200000f22",
"value": "xxxxxxxxx"
}],
"providerTypes": ["WATCHLIST"],
"entityType": "ORGANISATION",
"groupId": "xxxxx-xxxx-xxxx-xxxx-eXXXXXX",
"caseId": "",
"name": "ABC Logistics Trust2"
}

If you are still receiving Error 401, please provide us the request and the response headers along with the request body to have a look into the issue again.

10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.