Open link in a new tab

Content

Expand project menu

API Queries

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

Message actions

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

Message actions

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

301 Moved Permanently

301 Moved Permanently


nginx/1.9.6 ` Where i mistake?
Message actions

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

Message actions

Hi,

I found my problem.

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

Thanks