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