Skip to content

Value cannot be null. (Parameter 'source') - Create Search Request - Issue #226

@ayaz-ahmed89

Description

@ayaz-ahmed89

Dear All,

I am getting this issue in qa environment locally it works fine. Request and config all same in local env and qa environment. I am stuck in this check all the possibility but still getting null issue in QA while code reach this line "var data = apiInstance.CreateSearch(requestObj);"

below is request and response.

Request :

private CyberSource.Model.TssV2TransactionsPost201Response CreateCyberSourceSearch(string item)
{
try
{
var requestObj = new CyberSource.Model.CreateSearchRequest()
{
Save = false,
Name = "TSS search",
Timezone = "Asia/Dubai",
Query = string.Format("{0}:{1}", "clientReferenceInformation.code", item),
Offset = 0,
Limit = 10,
Sort = "id:asc, submitTimeUtc:asc"
};

      var configDictionary = new CyberSourceConfiguration(false).GetConfiguration(); 
      var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); 
      var apiInstance = new SearchTransactionsApi(clientConfig);
      if (apiInstance != null)
      {
        _logger.LogInformation("apiInstance: " + JsonConvert.SerializeObject(apiInstance.Configuration.ClientId));

      }
      else
      {
           _logger.LogError("apiInstance is null");
      }
      var data = apiInstance.CreateSearch(requestObj);
      if (data != null)
      { 
                    _logger.LogInformation("data: " + JsonConvert.SerializeObject(data));
      }
      else
      { 

_logger.LogError("data is null");
}
return data;
}
catch (Exception ex)
{
_logger.LogError("Exception on calling the API: " + ex.Message);
return null;
}
}

Response :

Error Occurred in CreateSearchRequest method: Value cannot be null. (Parameter 'source')-- at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at CyberSource.Client.ApiClient.CallApi(String path, Method method, Dictionary2 queryParams, Object postBody, Dictionary2 headerParams, Dictionary2 formParams, Dictionary2 fileParams, Dictionary2 pathParams, String contentType, Boolean isResponseMLEForApi) at CyberSource.Api.SearchTransactionsApi.CreateSearchWithHttpInfo(CreateSearchRequest createSearchRequest) at CyberSource.Api.SearchTransactionsApi.CreateSearch(CreateSearchRequest createSearchRequest)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions