Clone wiki

BibSonomy / documentation / api / methods / CreatePost

Add post

Method POST
URL https://www.bibsonomy.org/api/users/[username]/posts

Status codes

  • 201 created

  • 400 bad request

  • 401 Unauthorized
  • 403 Forbidden

  • 500 Internal Server Error

Example

Using XML

Request:

curl -XPOST --user username:apikey "https://www.bibsonomy.org/api/users/username/posts" --header "Content-Type:application/xml" -d '
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<bibsonomy>
  <post description="some important bookmark!">
    <user name="username"/>
    <tag name="tag1"/>
    <tag name="tag2"/>
    <tag name="tag3"/>
    <group name="public"/>
    <bookmark url="http://www.example.com/" title="An exemplary website"/>
  </post>
</bibsonomy>'

Response:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<bibsonomy stat="ok">
  <resourcehash>f1777111f5d0f1c81ffa04de751128fa</resourcehash>
</bibsonomy>

Using JSON

Request:

curl -XPOST --user username:apikey "https://www.bibsonomy.org/api/users/username/posts" --header "Content-Type:application/json" -d '
{
    "post": {
        "bibtex": {
            "author": "Adams, Douglas", 
            "bibtexKey": "hitchhickersguide", 
            "entrytype": "book", 
            "title": "The Hitchhiker'\''s Guide to the Galaxy", 
            "year": "1979"
        }, 
        "group": [
            {
                "name": "public"
            }
        ], 
        "tag": [
            {
                "name": "tag1"
            }, 
            {
                "name": "tag2"
            },
            {
                "name": "tag3"
            }
        ], 
        "user": {
            "name": "username"
        },
        "description" : "Cool book"
    }
}'

Response:

{"resourcehash":"74ef4b0e6cbfdebdf8411c0ea304abc7","stat":"ok"}

Using Multipart files

You can also post your publications with multipart requests. The request contains two parts: A XML or JSON file containing the post informations (username, tags and posts) and a file containing the publication in a supported format (e. g. BibTeX; see below for a complete list of supported formats).

post.xml:

<bibsonomy>
  <post>
    <user name="username"/>
    <tag name="tag1"/>
    <group name="public"/>
    <bibtex title="x" year="x" author="x" bibtexKey="x" entrytype="x"/>
    <publicationFileUpload multipartName="bibtex" />
  </post>
</bibsonomy>

publication.bib:

@book{zannetti2013air,
  author = {Zannetti, Paolo},
  publisher = {Springer Science \& Business Media},
  title = {Air Pollution Modeling: Theories, computational methods and available software},
  year = 2013
}

Request:

curl --user username:apikey -F "main=@post.xml" -F "bibtex=@publication.bib;type=text/bibtex" https://www.bibsonomy.org/api/users/username/posts

The main part always contains the XML/JSON, which also specifies which part (multipartName of the publicationFileUpload element) will be parsed to post a publication.

Please make sure that you set the content type of the multipart file.

The following formats are supported:

  • text/bibtex: BibTeX
  • application/marc: MARC
  • application/marc:application/pica

The bibtex element is optional. When a bibtex element is provided, fields of the parsed publication are merged with the field data from the bibtex element (if a field is not present in the parsed publication, the field of the provided bibtex element is used).

XML Schema

<!--
  a post
-->

<xsd:complexType name="PostType">
  <xsd:sequence>
    <xsd:element name="user" type="UserType" />
    <xsd:element maxOccurs="unbounded" minOccurs="0" name="group" type="GroupType" />
    <!-- Note: a post must have at least one tag -->
    <xsd:element maxOccurs="unbounded" name="tag" type="TagType" />             
    <xsd:element minOccurs="0" maxOccurs="1" name="documents" type="DocumentsType" />
    <xsd:choice>
      <xsd:element name="bookmark" maxOccurs="1" type="BookmarkType" />
      <xsd:element name="bibtex" maxOccurs="1" type="BibtexType" />
      <xsd:element name="publicationFileUpload" maxOccurs="1" type="UploadDataType" />
      <xsd:element name="goldStandardPublication" maxOccurs="1" type="GoldStandardPublicationType" />
    </xsd:choice>
  </xsd:sequence>
  <xsd:attribute name="description" type="xsd:string" />
  <xsd:attribute name="postingdate" type="xsd:dateTime" />
  <xsd:attribute name="changedate" type="xsd:dateTime" />
</xsd:complexType>

<!--
  a bookmark
-->
<xsd:complexType name="BookmarkType">
  <xsd:attribute name="title" type="xsd:string" use="required" />
  <xsd:attribute name="url" type="xsd:anyURI" use="required" />

  <!-- hash value identifying this resource -->
  <xsd:attribute name="interhash" type="xsd:string" />
  <xsd:attribute name="intrahash" type="xsd:string" />
  <!-- link to all posts of this bookmark -->
  <xsd:attribute name="href" type="xsd:anyURI" />
</xsd:complexType>


<!--
  a publication
-->
<xsd:complexType name="AbstractPublicationType">
  <xsd:attribute name="title" type="xsd:string" use="required" />
  <xsd:attribute name="bibtexKey" type="xsd:string" />
  <xsd:attribute name="bKey" type="xsd:string" />
  <xsd:attribute name="misc" type="xsd:string" />
  <xsd:attribute name="bibtexAbstract" type="xsd:string" />
  <xsd:attribute name="entrytype" type="xsd:string" />
  <xsd:attribute name="address" type="xsd:string" />
  <xsd:attribute name="annote" type="xsd:string" />
  <xsd:attribute name="author" type="xsd:string" />
  <xsd:attribute name="booktitle" type="xsd:string" />
  <xsd:attribute name="chapter" type="xsd:string" />
  <xsd:attribute name="crossref" type="xsd:string" />
  <xsd:attribute name="edition" type="xsd:string" />
  <xsd:attribute name="editor" type="xsd:string" />
  <xsd:attribute name="howpublished" type="xsd:string" />
  <xsd:attribute name="institution" type="xsd:string" />
  <xsd:attribute name="organization" type="xsd:string" />
  <xsd:attribute name="journal" type="xsd:string" />
  <xsd:attribute name="note" type="xsd:string" />
  <xsd:attribute name="number" type="xsd:string" />
  <xsd:attribute name="pages" type="xsd:string" />
  <xsd:attribute name="publisher" type="xsd:string" />
  <xsd:attribute name="school" type="xsd:string" />
  <xsd:attribute name="series" type="xsd:string" />
  <xsd:attribute name="volume" type="xsd:string" />
  <xsd:attribute name="day" type="xsd:string" />
  <xsd:attribute name="month" type="xsd:string" />
  <xsd:attribute name="year" type="xsd:string" />
  <xsd:attribute name="type" type="xsd:string" />
  <xsd:attribute name="url" type="xsd:string" />
  <xsd:attribute name="privnote" type="xsd:string" />

  <!-- hash value identifying this resource -->
  <xsd:attribute name="intrahash" type="xsd:string" />
  <xsd:attribute name="interhash" type="xsd:string" />
  <!-- link to all posts of this publication -->
  <xsd:attribute name="href" type="xsd:anyURI" />
</xsd:complexType>

<!--
    a publication
-->
<xsd:complexType name="BibtexType">
  <xsd:complexContent>
    <xsd:extension base="AbstractPublicationType">
    </xsd:extension>
  </xsd:complexContent>
</xsd:complexType>


<!--
  a user
-->
<xsd:complexType name="UserType">
  <xsd:sequence>
    <xsd:element name="groups" type="GroupsType" minOccurs="0" maxOccurs="1">
  </xsd:sequence>
  <xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>

<!--
  a tag
-->
<xsd:complexType name="TagType">
  <xsd:sequence>
    <xsd:element maxOccurs="unbounded" minOccurs="0" name="subTags" type="TagsType" />
    <xsd:element maxOccurs="unbounded" minOccurs="0" name="superTags" type="TagsType" />
  </xsd:sequence>
  <xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>

Updated