Article

CRUD endpoints for a user's articles

Please note that in all urls & code samples you'll need to replace:username and :corporation with appropriate values

Get All Articles

GET /v2/organization/:corporation/expert/:username/article

Headers

NameValue

Content-Type

application/json

Authorization

Bearer <token>

Url

NameTypeDescription

corporation

number

Corporation ID

username

string

Unique username

Response

{
  data: [
    {
      id: 1,
      title: 'Article Title',
      publisher: '',
      details: '',
      date: 0,
      url: 'https://myurl.com',
      authors: ''
    },
  ],
  success: true
}

Code

const accessToken = `<ACCESS TOKEN>`

fetch('https://public-api.expertfile.com/v2/organization/:corporation/expert/:username/article', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': `Bearer ${accessToken}`
    }
})
.then(response => response.json())
.then(json => {
    const { success, data } = json

    if (success) {
        const articles = data;
        console.log('all articles', articles)
    }

})
.catch(error => console.error(error));

Get Individual Article

GET /v2/organization/:corporation/expert/:username/article/:id

Headers

NameValue

Content-Type

application/json

Authorization

Bearer <token>

Url

NameTypeDescription

corporation

number

Corporation ID

username

string

Unique username

id

number

Article ID

Response

{
  data: [
    {
      id: 1,
      title: 'Article Title',
      publisher: '',
      details: '',
      date: 0,
      url: 'https://myurl.com',
      authors: ''
    },
  ],
  success: true
}

Code

const accessToken = `<ACCESS TOKEN>`

fetch('https://public-api.expertfile.com/v2/organization/:corporation/expert/:username/article/:id', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': `Bearer ${accessToken}`
    }
})
.then(response => response.json())
.then(json => {
    const { success, data } = json

    if (success) {
        const article = data;
        console.log('article', article)
    }

})
.catch(error => console.error(error));

Create Article

POST /v2/organization/:corporation/expert/:username/article

Headers

NameValue

Content-Type

application/json

Authorization

Bearer <token>

Url

NameTypeDescription

corporation

number

Corporation ID

username

string

Unique username

Body

NameTypeDescription

title*

string

Article Title

details*

string

Article Details

url

string

Article Url

publisher*

string

Article Publisher

authors

string

Article Authors

Response

{ 
    data: { 
        id: 1
    }, 
    success: true 
}

Code

const data = new URLSearchParams();
const accessToken = `<ACCESS TOKEN>`

data.append('title', 'Article title');
data.append('details', 'Article details...');
data.append('url', 'https://myurl.com');
data.append('publisher', 'Article publishers...');
data.append('authors', 'Article authors');

fetch('https://public-api.expertfile.com/v2/organization/:corporation/expert/:username/article', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': `Bearer ${accessToken}`
    },
    body: data
})
.then(response => response.json())
.then(json => {
    const { success, data, error } = json

    if (success) {
        const { id } = data
        console.log('New article id', id)
    }

})
.catch(error => console.error(error));

Update Article

PUT /v2/organization/:corporation/expert/:username/article/:id

Headers

NameValue

Content-Type

application/json

Authorization

Bearer <token>

Url

NameTypeDescription

corporation

number

Corporation ID

username

string

Unique username

id

number

Article ID

Body

NameTypeDescription

title*

string

Article Title

details*

string

Article Details

url

string

Article Url

publisher*

string

Article Publisher

authors

string

Article Authors

Response

{ 
    data: { 
        id: 1, 
        updated: true 
    }, 
    success: true 
}

Code

const data = new URLSearchParams();
const accessToken = `<ACCESS TOKEN>`

data.append('title', 'Article title');
data.append('details', 'Article details...');
data.append('url', 'https://myurl.com');
data.append('publisher', 'Article publishers...');
data.append('authors', 'Article authors');

fetch('https://public-api.expertfile.com/v2/organization/:corporation/expert/:username/article/:id', {
    method: 'PUT',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': `Bearer ${accessToken}`
    },
    body: data
})
.then(response => response.json())
.then(json => {
    const { success, data, error } = json

    if (success) {
        const { id } = data
        console.log('New article id', id)
    }

})
.catch(error => console.error(error));

Delete Article

DELETE /v2/organization/:corporation/expert/:username/article/:id

Headers

NameValue

Content-Type

application/json

Authorization

Bearer <token>

Url

NameTypeDescription

corporation

number

Corporation ID

username

string

Unique username

id

number

Article ID

Response

{ 
    data: { 
        deleted: true, 
        id: 1 
    }, 
    success: true 
}

Code

const accessToken = `<ACCESS TOKEN>`

fetch('https://public-api.expertfile.com/v2/organization/:corporation/expert/:username/article/:id', {
    method: 'DELETE',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': `Bearer ${accessToken}`
    }
})
.then(response => response.json())
.then(json => {
    const { success, data, error } = json

    if (success) {
        const { id } = data
        console.log('Deleted article id', id)
    }

})
.catch(error => console.error(error));

Last updated