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

Development
  1. OpenProject
  2. Forums
  3. Development
  4. OpenProject REST API

OpenProject REST API

Added by Andreas Wagner over 4 years ago

We are trying to add a work_package to the OpenProject server. We succeed doint so using Postman and the payload used in the script. When trying to post using jQuery we are receiving a CORS Error - allthough we post from the same machine - so we are quite sure it has nothing to do with CORS. More likely it is an issue with how the auth header is set .... We cannot find any sample on how to set it correctly in this forum or the internet. Can anyone please provide a working example?
  const data = { "subject": "Variable_2_Titel", "description": { "format": "textile", "raw": "Variable_2_Beschreibung+Username in neuer Zeile Wennder hacken nicht gesetzt" }, "_links": { "type": { "href": "/api/v3/types/1", "title": "Arbeitspaket", "status": { "href": "/api/v3/statuses/1", "title": "Neu" }, "priority": { "href": "/api/v3/priorities/8", "title": "Normal" } } } };

const posturl = "http://xxxopenproject.xxxx.local/api/v3/projects/innovmgmt/work_packages";

  $.ajax({

    type: 'POST',

    url: posturl,

    data: JSON.stringify(data),

    contentType: 'application/json',

    xhrFields: {

      withCredentials: true

    },

    beforeSend: function (xhr) {

      xhr.setRequestHeader("Authorization", "Basic " + btoa("Credentials: apikey:xxxxxxbd66a3e1445419de6c961076aa9c2b4b6"));

    },

    success: function () {

      alert('Worked');

    },

    error: function (err) {

      console.log(err);

    }

  });


Replies (2)

RE: OpenProject REST API - Added by Max Mutzge over 4 years ago

Dear Andreas,
I guess you already found our documentation (https://docs.openproject.org/api/)? Next week we will release a revised and extended version when releasing OpenProject 11.0

Kind regards

Matthias

RE: OpenProject REST API - Added by Andreas Wagner over 4 years ago

Hi,

thank you for your feedback, yes the documentation is known to us. In the meantime we came across an interesting article.

https://community.openproject.com/projects/openproject/work_packages/34054/activity

So we are eagerly waiting for the new version and hope that it works with it.

Andreas

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