Article
CRUD endpoints for a user's articles
Get All Articles
GET
/v2/organization/:corporation/expert/:username/article
Headers
Content-Type
application/json
Authorization
Bearer <token>
Url
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
Content-Type
application/json
Authorization
Bearer <token>
Url
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
Content-Type
application/json
Authorization
Bearer <token>
Url
corporation
number
Corporation ID
username
string
Unique username
Body
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
Content-Type
application/json
Authorization
Bearer <token>
Url
corporation
number
Corporation ID
username
string
Unique username
id
number
Article ID
Body
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
Content-Type
application/json
Authorization
Bearer <token>
Url
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
Was this helpful?