cancel
Showing results for 
Search instead for 
Did you mean: 

ExceptionMessage":"Object reference not set to an instance of an object.

arjuninfo
New Contributor

Hi Team,

I am using the Shipment CreateLabel API in php, but I am getting the following error

 

 

{"Message":"An error has occurred.","ExceptionMessage":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","StackTrace":"   at SS.OpenApi.Controllers.ShipmentsController._CreateLabel(LabelRequest request, MapperStrategy mapStrategy) in D:\\buildAgentFull\\work\\8e15a453e647e65a\\SS.OpenApi\\Controllers\\ShipmentsController.cs:line 237\r\n   at SS.OpenApi.Controllers.ShipmentsController.CreateLabel(LabelRequest request) in D:\\buildAgentFull\\work\\8e15a453e647e65a\\SS.OpenApi\\Controllers\\ShipmentsController.cs:line 56\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}r

 

 

 

Here this is my php code

 

 

<?php

$curl = curl_init();
$ssApiKey = 'sadsadas';
$ssApiSecret = 'sadasdsad';
$authorizations = 'Basic '.base64_encode($ssApiKey.':'.$ssApiSecret);

$filters = array(
    "carrierCode"=> "fedex",
    "serviceCode"=>"fedex_ground",
    "packageCode"=>"package",
    'shipDate'=>'2024-02-02',
    "weight"=>array(
        "value"=>2,
        "units"=>"ounces"
    ),
    "shipFrom"=> array(
        "name"=>"Arjun Test Fedex",
        "company"=>"xxxx",
        "phone"=>"18139973776",
        "email"=>"arjun_csharp@xxx.com",
        "street1"=>"xxxxx",
        "city"=>"TAMPA",
        "state"=>"FL",
        "postalCode"=>"33619",
        "country"=>"US"
    ),
    "shipTo"=> array(
        "name"=>"Arjun Test Fedex",
        "company"=>"xxxx",
        "phone"=>"18139973776",
        "email"=>"arjun_csharp@xxx.com",
        "street1"=>"xxxxx",
        "city"=>"TAMPA",
        "state"=>"FL",
        "postalCode"=>"33619",
        "country"=>"US"
    ),
    "testLabel"=>false
);

$filter     = http_build_query($filters);


curl_setopt_array($curl, array(
    CURLOPT_URL => "https://ssapi.shipstation.com/shipments/createLabel",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS =>json_encode($filters),
    CURLOPT_HTTPHEADER => array(
        "Host: ssapi.shipstation.com",
        "Authorization: $authorizations",
        "Content-Type: application/json"
    ),
));

$response = curl_exec($curl);
curl_close($curl);

print_r($response);
exit;

 

 

 

Could you please help what I am doing wrong

1 REPLY 1

Hey there @arjuninfo

 

Welcome to the community! We are thrilled you've joined us. 

 

If we don't get any answers from other community members here, I would recommend reaching out to apisupport@shipstation.com for assistance 🙂 

From Moderator Davis, May the force be with you!