-
Notifications
You must be signed in to change notification settings - Fork 1
API Documentation
There are currently two ways of creating a shorty, either with a randomly generated unique identifier, or with a custom one you can choose yourself.
URL : /shorties/
Method : POST
Auth required : NO
Permissions required : None
Data constraints
Provide a JSON representation of the shorty you want to create
{
"fullUrl": "<string>"
}
Note that the fullUrl
field should contain a valid URL.
Data example
{
"fullUrl": "http://www.google.com/"
}
Code : 200 OK
Content example
Returns a JSON representation of a shorty object.
{
"fullUrl": "https://www.google.com/",
"shortIdentifier": "abcde"
}
URL : /shorties/custom/
Method : POST
Auth required : NO
Permissions required : None
Data constraints
Provide a JSON representation of the shorty you want to create
{
"fullUrl": "<string>",
"shortIdentifier": "<string>"
}
Note that the fullUrl
field should contain a valid URL.
Data example
{
"fullUrl": "http://www.google.com/",
"shortIdentifier": "iamcustom"
}
Condition : If everything is OK and a shorty with the same shortIdentifier
didn't exist.
Code : 201 CREATED
Content example
{
"fullUrl": "http://www.google.com/",
"shortIdentifier": "iamcustom"
}
Condition : If a a shorty with the same shortIdentifier
already exists.
Code : 409 CONFLICT
Content :
{
"timestamp": 1516904578585,
"status": 409,
"error": "Conflict",
"exception": "nl.joelchrist.shorty.exceptions.DuplicateShortyException",
"message": "A shorty with this shortIdentifier already exists.",
"path": "/shorties/custom"
}
Condition : If fields in the request are missing or invalid
Code : 400 BAD REQUEST
Content example
{
"timestamp": 1516904705569,
"status": 400,
"error": "Bad Request",
"exception": "org.springframework.web.bind.MethodArgumentNotValidException",
"errors": [{
"codes": ["URL.shorty.fullUrl", "URL.fullUrl", "URL.java.lang.String", "URL"],
"arguments": [{
"codes": ["shorty.fullUrl", "fullUrl"],
"arguments": null,
"defaultMessage": "fullUrl",
"code": "fullUrl"
},
[], {
"codes": [""],
"defaultMessage": "",
"arguments": null
}, -1, {
"codes": [""],
"defaultMessage": "",
"arguments": null
}, {
"codes": [".*"],
"defaultMessage": ".*",
"arguments": null
}
],
"defaultMessage": "A shorty's full url should be a valid url",
"objectName": "shorty",
"field": "fullUrl",
"rejectedValue": "df",
"bindingFailure": false,
"code": "URL"
}],
"message": "Bad Request",
"path": "/shorties/custom"
}