Your browser is outdated and unsupported. You may run into errors and degraded experience on this page. Please update your browser.
  • Help and support
  • 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

      Added by Andreas Wagner almost 3 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);

      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

      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

  •