Home Forums Support Create client in API returns NotFoundHttpException

This topic contains 2 replies, has 2 voices, and was last updated by  Hillel Coren 3 years, 11 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #515

    Anonymous

    Hi!
    I’m trying to access the API this way:

    
    ninja.dev/api/v1/clients -H "Content-Type:application/json" -d '{"name":"test client", "contact":{"email":"[email protected]"}}' -H "X-Ninja-Token: A2e2***the_token***SdRKZN5RZGXLZ"
    

    and I’m getting this page

    
    NotFoundHttpException in compiled.php line 7905:
    
        in compiled.php line 7905
        at RouteCollection->match(object(Request)) in compiled.php line 7176
        at Router->findRoute(object(Request)) in compiled.php line 7148
        at Router->dispatchToRoute(object(Request)) in compiled.php line 7140
        at Router->dispatch(object(Request)) in compiled.php line 2038
        at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
        at call_user_func(object(Closure), object(Request)) in compiled.php line 9190
        at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartupCheck.php line 160
        at StartupCheck->handle(object(Request), object(Closure)) in compiled.php line 9182
        at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in DuplicateSubmissionCheck.php line 28
        at DuplicateSubmissionCheck->handle(object(Request), object(Closure)) in compiled.php line 9182
        at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 2546
        at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 34
        at VerifyCsrfToken->handle(object(Request), object(Closure)) in compiled.php line 9182
        at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 12362
        at ShareErrorsFromSession->handle(object(Request), object(Closure)) in compiled.php line 9182
        at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 11052
        at StartSession->handle(object(Request), object(Closure)) in compiled.php line 9182
        at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 12064
        at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in compiled.php line 9182
        at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 12012
        at EncryptCookies->handle(object(Request), object(Closure)) in compiled.php line 9182
        at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 2587
        at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in compiled.php line 9182
        at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
        at call_user_func(object(Closure), object(Request)) in compiled.php line 9173
        at Pipeline->then(object(Closure)) in compiled.php line 1994
        at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 1981
        at Kernel->handle(object(Request)) in index.php line 53
    
    

    Also, if I just try

    
    ninja.dev/api/v1/clients -H "Content-Type:application/json" -H "X-Ninja-Token: A2e2QGPj**the_token**dRKZN5RZGXLZ"
    

    I get a blank page with INVALID TOKEN

    The token has been generated in Advanced Settings -> Tokens

    Any help?

    Thank you so much

    #516

    Anonymous

    Ok, I figured out how to GET clients

    for the POST, here’s what I’m getting:

    
    C:\Program Files\cURL\bin>curl -X POST ninja.dev/api/v1/clients -H "X-N
    inja-Token: A2e2QGPjshNFsOyNt1ySdRKZN5RZGXLZ" -H "Content-Type:application/json"
     -d '{"name":"test client", "contact":{"first_name":"Test", "email":"te
    [email protected]"}}'
    

    and the error is :

    
    {"email":["The email field is required when first name is not present."],"first_
    name":["The first name field is required when email is not present."]}curl: (3)
    [globbing] unmatched brace in column 9
    curl: (3) [globbing] unmatched close brace/bracket in column 21
    
    #517

    Hillel Coren
    Keymaster

    I’m not yet sure, the same command is working for me. Are you running the latest version of the code?

    You could try creating the contact as part of an array.

    curl -X POST ninja.dev/api/v1/clients -H “X-Ninja-Token: TOKEN” -H “Content-Type:application/json” -d ‘{“name”:”test client”, “contacts”:[{“first_name”:”Test”, “email”:”[email protected]”}]}’

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Posted in: