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. API Queries

API Queries

Added by Mesmeric Shaolin over 9 years ago

Hello,

Firstly apologies about the noob question but I am a little confused. I am just trying to build up some basic querying via the API (v3), just pulling out information for now, however i am not getting very far.

If for example i visit the following url in my browser, i am presented with the JSON output as expected.

http://my_url/api/v3/work_packages/120

However, if i try to do a basic web request from powershell, python or curl I am presented with a ‘NotFound’ error.

Powershell:
Invoke-WebRequest -Uri "http://my_url/api/v3/work_packages/120"

Python:
import urllib2 content = urllib2.urlopen("http://my_url/api/v3/work_packages/120") print (content.read())

Curl:
curl http://my_url/api/v3/work_packages/120

The error i get each time is..
{"_type":"Error","errorIdentifier":"urn:openproject-org:api:v3:errors:NotFound","message":"The requested resource could not be found.","_embedded":{}}

I have kept the requests as simple as possible to reduce any margin for error. One point to take into account which makes this even more frustrating is that executing the following URL with any of the methods above works fine.

http://my_url/api/v3/users/4

Any help would be much appreciated.

Many thanks in advance

Mesmeric


Replies (4)

RE: API Queries - Added by Marion Nette over 9 years ago

As far as I know, you need to include the api key in the request.

This one works for me:

curl -X GET -u apikey:5b....85 http://host/api/v3/work_packages/1

The api-key is in Administration -> System Settings -> Repositories

RE: API Queries - Added by Anatolij Yakymets almost 9 years ago

I try this
curl -X GET -u apikey:5b....85 http://host/api/v3/work_packages/1
command in terminal and hand this answer
`

<title>301 Moved Permanently</title>

301 Moved Permanently


nginx/1.9.6 ` Where i mistake?

RE: API Queries - Added by Xavier Misseri about 5 years ago

Dear all,

I try to make a first API request but it does not work.

I simply use the following command:

curl -X GET -u apikey:XXX http://host/api/v3/work_packages/1

What I don't understand is that openproject gives me a Client ID and a Client secret but only an apikey is used on the example above.

Anyone can help me  ?

I use openproject v10.4.1

Thanks

Xavier

RE: API Queries - Added by Xavier Misseri about 5 years ago

Hi,

I found my problem.

I was using Auth2 api keys whereas it works with the user account api key.

Thanks

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