wiki:SoftwareDevelopment/EPIC/APIv2

Version 15 (modified by Sander Maijers, 8 years ago) (diff)

contents: update examples based on epic-announce message Thu, 3 Mar 2016 08:57:04 +0000

EPIC API v2

Test account

Production environment

Prefix 11372

Prefix 11459

GWDG contact

GWDG, Handle <handle@gwdg.de>

Documentation

Usage examples

Taken from http://epic.gwdg.de/wiki/index.php/EPIC:API:v2:contribution:

The current PID-Service requires HTTP BASIC AUTH authentication, use the -u parameter.

A) In order to get a JSON response specify application/json in the "Accept" header field:

curl  -vv -u "user:pass" -H "Content-Type:application/json"  -H "Accept:application/json" -X POST --data '[{"type":"URL","parsed_data":"http://www.gwdg.de"}]' http://pid.gwdg.de/handles/$PREFIX

B) In order to get a HTML response specify text/html in the "Accept" header field:

curl  -vv -u "user:pass" -H "Content-Type:application/json"  -H "Accept:text/html" -X POST --data '[{"type":"URL","parsed_data":"http://www.gwdg.de"}]' http://pid.gwdg.de/handles/$PREFIX

C) In order to get a XHTML response specify application/xhtml+xml in the "Accept" header field:

curl  -vv -u "user:pass" -H "Content-Type:application/json"  -H “Accept:application/xhtml+xml" -X POST --data '[{"type":"URL","parsed_data":"http://www.gwdg.de"}]' http://pid.gwdg.de/handles/$PREFIX

VIEW

  • VIEW the PID 11022/1234-5678-1234-C in HTML format:
    curl -u 'tkalman:MyPaSsWoRd' http://pid.gwdg.de/handles/11022/1234-5678-1234-C
    
  • VIEW the PID 11022/1234-5678-1234-C in JSON format (Accept: header):
    curl -u 'tkalman:MyPaSsWoRd' -H "Accept:application/json" http://pid.gwdg.de/handles/11022/1234-5678-1234-C
    

(Note the Accept:application/json header.)

CREATE

  • Creating a PID for the URL "http://www.gwdg.de/TEST/abcdef":
    curl -u 'tkalman:MyPaSsWoRd' -H "Accept:application/json" -H "Content-Type:application/json" '''-X POST''' --data ''''[{"type":"URL","parsed_data":"http://www.gwdg.de/TEST/abcdef"}]'''' http://pid.gwdg.de/handles/11022/
    

UPDATE

  • Updating the PID 11022/1234-5678-1234-C:

Use the PUT method to update the Handle 11022/1234-5678-1234-C:

curl -u 'tkalman:MyPaSsWoRd' -H "Accept:application/json" -H "Content-Type:application/json" -X '''PUT''' --data '[{"type":"URL","parsed_data":"http://www.gwdg.de/TEST/newurl"}]' http://pid.gwdg.de/handles/'''11022/1234-5678-1234-C''