Last active
November 15, 2019 15:06
-
-
Save topless/635bf854516afb185d35fedca51f8d85 to your computer and use it in GitHub Desktop.
Marshmallow test requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create | |
curl -k --header "Content-Type: application/json" --request POST \ | |
--data '{"title":"Some title", "contributors": [{"name": "Doe, John"}]}' \ | |
https://localhost:5000/api/records/\?prettyprint\=1 | |
curl -k --header "Content-Type: application/json" --request POST \ | |
--data '{"title":"This is a title indeed", "contributors": [{"name": "Da Chris, Pop"}]}' \ | |
https://localhost:5000/api/records/\?prettyprint\=1 | |
# GET | |
curl -k --header "Content-Type: application/json" https://localhost:5000/api/records/\?prettyprint\=1 | |
curl -k --header "Content-Type: application/json" https://localhost:5000/api/records/1\?prettyprint\=1 | |
curl -k --header "Content-Type: application/json" https://localhost:5000/api/records/2\?prettyprint\=1 | |
# Succeed changing the tilte and contributor | |
curl -k --header "Content-Type: application/json" --request PUT \ | |
--data '{"title":"Changed the title", "contributors": [{"name": "Changed, One"}]}' \ | |
https://localhost:5000/api/records/1\?prettyprint\=1 | |
# Submit a different id, should work properly, id gets disregarded although is required in schema | |
curl -k --header "Content-Type: application/json" --request PUT \ | |
--data '{"id": "5", "title":"Another ID title", "contributors": [{"name": "Mairy, Pop"}]}' \ | |
https://localhost:5000/api/records/1\?prettyprint\=1 | |
# Submit wrong type of data int instead of string | |
# {"status": 400, "message": "Validation error.", "errors": [{"field": "title", "message": "Not a valid string."}]}% | |
curl -k --header "Content-Type: application/json" --request PUT \ | |
--data '{"title": 42, "contributors": [{"name": "Changed, One"}]}' \ | |
https://localhost:5000/api/records/1\?prettyprint\=1 | |
# Edit partial data | |
# {"status": 400, "message": "Validation error.", "errors": [{"field": "contributors", "message": "Missing data for required field."}]} | |
curl -k --header "Content-Type: application/json" --request PUT \ | |
--data '{"title":"A tilte misplead"}' \ | |
https://localhost:5000/api/records/2\?prettyprint\=1 | |
# Edit data with extra field | |
# {"status": 400, "message": "Validation error.", "errors": [{"field": "not_in_schema", "message": "Unknown field."}]} | |
curl -k --header "Content-Type: application/json" --request PUT \ | |
--data '{"not_in_schema": "thats right", "title":"A beautiful tilte misplead", "contributors": [{"name": "Mairy, Pop"}]}' \ | |
https://localhost:5000/api/records/1\?prettyprint\=1 | |
# Requests for files | |
# Upload a file | |
curl -i -X PUT --insecure --data-binary @my_file.txt \ | |
https://localhost:5000/files/e2f43059-57b5-4509-98ec-e0b9a9b1e15d/my_file.txt | |
# Get it | |
curl -k https://localhost:5000/files/e2f43059-57b5-4509-98ec-e0b9a9b1e15d\?prettyprint\=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment