- Core API's
- >
- Photos API
- >
- Photos - Create
Photos - Create API
Create a new Photo.
Method POST
Body
{
"title": "Sample Photo Title",
"url": "https:\/\/example.com\/sample.jpg",
"thumbnail_url": "https:\/\/example.com\/sample-thumbnail.jpg",
"album_id": 1
}
How to Use
fetch('https://simplecrudapi.com/api/photos', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: 'Beautiful Sunset',
description: 'A stunning view of the sunset over the mountains.',
url: 'https://via.placeholder.com/640x480.png/006644?text=enim'
})
})
.then(response => response.json())
.then(json => console.log(json))
.catch(error => console.error(error));
Response
{
"data": {
"id": 1,
"title": "Beautiful Sunset",
"description": "A stunning view of the sunset over the mountains.",
"url": "https:\/\/via.placeholder.com\/640x480.png\/000088?text=Sunset",
"uploaded_at": "2024-11-09 20:09:42"
}
}
Try Now
fetch('https://simplecrudapi.com/api/photos', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: 'Beautiful Sunset',
description: 'A stunning view of the sunset over the mountains.',
url: 'https://via.placeholder.com/640x480.png/006644?text=enim'
})
})
.then(response => response.json())
.then(json => console.log(json))
.catch(error => console.error(error));