Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API example from docs not working? #106

Closed
michielbdejong opened this issue Feb 12, 2023 · 5 comments
Closed

API example from docs not working? #106

michielbdejong opened this issue Feb 12, 2023 · 5 comments

Comments

@michielbdejong
Copy link
Contributor

Following the instructions from https://github.com/m-ld/timeld/blob/main/doc/api.md#import I see:

curl -X POST -d @./example.ndjson  -u $CREDENTIALS -H 'Content-Type: appon/x-ndjson' https://timeld.org/api/import
{"code":"InternalServer","message":"caused by Error: Could not parse row {\"@type\":\"Project\",\"@id\":\"org1/pr1\",\"external\":{\"@..."}

Did the API change or am I doing something wrong in my curl command?

This is the contents of example.ndjson:

cat example.ndjson 
{"@type":"Project","@id":"org1/pr1","external":{"@id":"http://ex.org/project/1"}}
{"@type":"Timesheet","@id":"org1/ts1","project":[{"@id":"org1/pr1"}],"external":{"@id":"http://ex.org/timesheet/1"}}
{"@type":"Entry","session":{"@id":"org1/ts1"},"activity":"orging","duration":60,"start":{"@value":"2022-06-22T16:40:55.946Z","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"vf:provider":{"@id":"test"},"external":{"@id":"http://ex.org/timesheet/1/entry/1"}}
@mcalligator
Copy link

Could you describe the setup you're using to do this? Is it straight from the GitHub repo, from the test suite that Yvo created, or the Docker images? That would help with reproducing the issue :-).

@michielbdejong
Copy link
Contributor Author

This is testing against your production server, note that the URL is https://timeld.org/api/import
You can just run this curl command as-is from any internet-connected machine, just make sure you set the $CREDENTIALS env var to <your-user> + : + <your-key>

@gsvarovsky
Copy link
Member

@michielbdejong
Copy link
Contributor Author

Ah. that helps! Added this in #107

But I'm still getting {"code":"Forbidden","message":""} as the response. That is probably because I need to replace the strings "org1/pr1" and "org1/ts1". How do I know which values to put in there?

@michielbdejong
Copy link
Contributor Author

Ah, I think I found mine - "fedb/fedt" and "fedb/from-ponder-source-testing", with the following I get a 200 response:

{"@type":"Project","@id":"fedb/fedt","external":{"@id":"http://ex.org/project/1"}}
{"@type":"Timesheet","@id":"fedb/from-ponder-source-testing","project":[{"@id":"fedb/fedt"}],"external":{"@id":"http://ex.org/timesheet/1"}}
{"@type":"Entry","session":{"@id":"fedb/from-ponder-source-testing"},"activity":"orging","duration":60,"start":{"@value":"2022-06-22T16:40:55.946Z","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"vf:provider":{"@id":"test"},"external":{"@id":"http://ex.org/timesheet/1/entry/1"}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants