Skip to content

Instantly share code, notes, and snippets.

@marcobehlerjetbrains
Last active December 29, 2023 22:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save marcobehlerjetbrains/3b9ed46953f810160e3a47e81f88e027 to your computer and use it in GitHub Desktop.
Save marcobehlerjetbrains/3b9ed46953f810160e3a47e81f88e027 to your computer and use it in GitHub Desktop.
Spring Boot REF2 - Http Post
(async function createPhoto() {
let photo = {"fileName": "hello.jpg"};
await fetch("http://localhost:8080/photoz", {
method: "POST",
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify(photo)
})
.then(result => result.text())
.then(text => alert(text));
})();
@twoodruff01
Copy link

in line 2, "filename" should be "fileName" instead.

@Andile-Rodney
Copy link

thanks @twoodruff01 , was getting frustrated why my files kept creating nulls. thanks for the correction.

@Sihamharimech1
Copy link

the console is giving me an error
POST http://localhost:8080/photoz 405 (Method Not Allowed)
I understand it is for security, I searched in stackoverflow but all what i could find are outdated answers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment