Top Menu

Jump to content
Home
    Modules
      • Projects
      • Activity
      • Work packages
      • Gantt charts
      • Calendars
      • Team planners
      • Boards
      • News
    • Getting started
    • Introduction video
      Welcome to OpenProject Community
      Get a quick overview of project management and team collaboration with OpenProject. You can restart this video from the help menu.

    • Help and support
    • Upgrade to Enterprise edition
    • User guides
    • Videos
    • Shortcuts
    • Community forum
    • Enterprise support

    • Additional resources
    • Data privacy and security policy
    • Digital accessibility (DE)
    • OpenProject website
    • Security alerts / Newsletter
    • OpenProject blog
    • Release notes
    • Report a bug
    • Development roadmap
    • Add and edit translations
    • API documentation
  • Sign in
      Forgot your password?

      or sign in with your existing account

      Google

Side Menu

  • Overview
  • Activity
    Activity
  • Roadmap
  • Work packages
    Work packages
  • Gantt charts
    Gantt charts
  • Calendars
    Calendars
  • Team planners
    Team planners
  • Boards
    Boards
  • News
  • Forums

Content

General discussion
  1. OpenProject
  2. Forums
  3. General discussion
  4. api & /api/v3/projects/{id}/copy endpoint & project_statuses_pkey

api & /api/v3/projects/{id}/copy endpoint & project_statuses_pkey

Added by marc rcdevs over 2 years ago

Hi,

I am using

OpenProject 12.3.3 

PostgreSQL version 13.7

When I try to use the api to copy a project to create a new one I get this error:

( where my endpoint is /api/v3/projects/23/copy as 23 is the id of template I am trying to use and in the header I just have the name of the new project)

2022-11-23 16:00:52.927 UTC [38] ERROR:  duplicate key value violates unique constraint "project_statuses_pkey"

2022-11-23 16:00:52.927 UTC [38] DETAIL:  Key (id)=(23) already exists.

2022-11-23 16:00:52.927 UTC [38] STATEMENT:  INSERT INTO "project_statuses" ("id", "project_id", "explanation", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"

Is this a bug or am I doing something wrong ?


Replies (3)

RE: api & /api/v3/projects/{id}/copy endpoint & project_statuses_pkey - Added by Adam Szabo over 2 years ago

Hey,

The sentence: please share your APIv3 call in your code

'I try to use the api to copy a project to create a new one' is not an APIv3 syntax :)

I cannot answer your question if I do not see the APIv3 call

RE: api & /api/v3/projects/{id}/copy endpoint & project_statuses_pkey - Added by marc rcdevs over 2 years ago

Yes apologies !

When I try by an API call to create a copy of a project, I get this error:

....

Here is my api call, it very simple. the error is in my db log

auth = HTTPBasicAuth('apikey', ‘xxxxxxx’)
ServerIP = ‘X.X.X.X’
IDTemplate = ’34’

def create_project(CustumerID,CustumerName):
    print(f'create Project {ProjectID} with {ProjectName}')
    url_cr = f'https://{ServerIP}/api/v3/projects/{IDTemplate}/copy'
    json_cr = {'name': ProjectName, 'customField9': ProjectID}
    cr = requests.post(url_cr, json=json_cr, auth=auth, verify=False)
    ....
    pprint(cr.json())
    ...

RE: api & /api/v3/projects/{id}/copy endpoint & project_statuses_pkey - Added by marc rcdevs over 2 years ago

If I try with a different project I have the same problem

Url endpoint: /api/v3/projects/139/copy

Same payload json {'name': 'test', 'customField9': 'test'}

logs db:

2022-11-29 13:56:23.817 UTC [38] ERROR:  duplicate key value violates unique constraint "project_statuses_pkey"

2022-11-29 13:56:23.817 UTC [38] DETAIL:  Key (id)=(93) already exists.

2022-11-29 13:56:23.817 UTC [38] STATEMENT:  INSERT INTO "project_statuses" ("id", "project_id", "explanation", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"

with in the db:

openproject=# SELECT * FROM project_statuses where project_id=139;
id | project_id | explanation | code |          created_at           |          updated_at        
----+------------+-------------+------+-------------------------------+-------------------------------
93 |        139 |             |      | 2022-11-29 13:52:24.923032+00 | 2022-11-29 13:52:24.923032+00

  • (1 - 3/3)
Loading...