javascriptexact-online

Creating a single exact project, POST results in 500 error


I have access to Exact (OAUTH), access-, refresh-tokens, division No. ...
I get, 'GET' information From Exact API.
But I have problems in 'POST'-ing a new project, using Exact API.
And I have no Clue what is the problem.

As a user, I have 'POST' privileges ().

https://start.exactonline.nl/api/v1/2999609/Users/UserHasRights?endpoint='project/Projects'&action='POST' => true

I've no clue what to do next. Maybe I need to provide more data, but the documentations, state those three fields are enough to create a project.

const data = {
    "Code":"P99A",
    "Description":"P99A Descr",
    "Type": 1
}

const response = await fetch('https://start.exactonline.nl/api/v1/2999609/project/Projects', {  
    method: 'POST',  
    headers: {  
        'Accept': 'application/json',  
        'Content-Type': 'application/json',  
        'Prefer': 'return=representation',  
        'Authorization': `Bearer ${accessToken}`  
    },
    body: JSON.stringify(data)
})
console.log(response)

Exact Server response:

Response {  
  size: 0,  
  timeout: 0,  
  [Symbol(Body internals)]: {  
    body: PassThrough {  
      _readableState: [ReadableState],  
      _events: [Object: null prototype],  
      _eventsCount: 2,  
      _maxListeners: undefined,  
      _writableState: [WritableState],  
      allowHalfOpen: true,  
      [Symbol(kCapture)]: false,  
      [Symbol(kCallback)]: null  
    },  
    disturbed: false,  
    error: null  
  },  
  [Symbol(Response internals)]: {  
    url: 'https://start.exactonline.nl/api/v1/2999609/project/Projects',  
    status: 500,  
    statusText: 'Internal Server Error',  
    headers: Headers { [Symbol(map)]: [Object: null prototype] },  
    counter: 0  
  }  
}  

Solution

  • Please try with a different value for Type : 4 means Non-billable which requires no other fields normally. API Documentation shows that 1 is for Campaign. That value is not available via UI.