Im trying to fetch an give data to a POST-method getNumbers in the server, that has a parameter id, which simply returns the id for debugging purposes. So in the Client i do as following:
documentClickHandler=(number)=> {
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ id: number })
};
fetch("http://localhost:5000/api/Documents/GetNumber", requestOptions)
.then(response => response.json())
.then(result => console.log(result))
.catch(error => { console.log('request failed', error); });
}
Which only has the purpuse to give the id to the getNumber method in the server:
[HttpPost("GetNumber")]
public string GetNumber([FromBody] string id)
return id;
}
This gives me an error (400 bad request) and I dont know how to solve it. Any ideas? Im in desperate need of help.
