Web Api 2 call from axios Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceCalling the base constructor in C#Virtual member call in a constructorCall one constructor from anotheraxios get - multiple api calls with response from first api to subsequent callsaxios in response.headers doesn't show the x-operationaxios post request to send form dataUpload image file to server node.js express axiosposting form data with Axios to .NET APIposting from AxiosKey value is missing when I use axios
Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?
How to say that you spent the night with someone, you were only sleeping and nothing else?
Can a zero nonce be safely used with AES-GCM if the key is random and never used again?
Need a suitable toxic chemical for a murder plot in my novel
What would be Julian Assange's expected punishment, on the current English criminal law?
What are the performance impacts of 'functional' Rust?
Do working physicists consider Newtonian mechanics to be "falsified"?
Area of a 2D convex hull
How is simplicity better than precision and clarity in prose?
What items from the Roman-age tech-level could be used to deter all creatures from entering a small area?
Stop battery usage [Ubuntu 18]
Can a monk deflect thrown melee weapons?
What is the order of Mitzvot in Rambam's Sefer Hamitzvot?
New Order #5: where Fibonacci and Beatty meet at Wythoff
Complexity of many constant time steps with occasional logarithmic steps
How should I respond to a player wanting to catch a sword between their hands?
Is drag coefficient lowest at zero angle of attack?
How to rotate it perfectly?
How to market an anarchic city as a tourism spot to people living in civilized areas?
Jazz greats knew nothing of modes. Why are they used to improvise on standards?
Determine whether f is a function, an injection, a surjection
Training a classifier when some of the features are unknown
What did Darwin mean by 'squib' here?
What do you call the holes in a flute?
Web Api 2 call from axios
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceCalling the base constructor in C#Virtual member call in a constructorCall one constructor from anotheraxios get - multiple api calls with response from first api to subsequent callsaxios in response.headers doesn't show the x-operationaxios post request to send form dataUpload image file to server node.js express axiosposting form data with Axios to .NET APIposting from AxiosKey value is missing when I use axios
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
When I make a call to web api 2 from axios, the HttpPostedFileaBase is coming in as null. I can't figure out what is wrong.
[HttpPost]
public IHttpActionResult Upload(Config config)
//config.Name has value
//config.File is null
Here is the axios call:
const data =
Name:'john',
File: event.target.files[0] //this has value here
const config = headers: 'content-type': 'multipart/form-data'
axios(
method: 'post',
url: '/api/upload',
data: data,
config
)
.then((response) =>
)
}).catch(err => console.log(err));
I can see the file when I console.log
, but when it gets to the api call, it is null
c# reactjs asp.net-web-api2 axios
add a comment |
When I make a call to web api 2 from axios, the HttpPostedFileaBase is coming in as null. I can't figure out what is wrong.
[HttpPost]
public IHttpActionResult Upload(Config config)
//config.Name has value
//config.File is null
Here is the axios call:
const data =
Name:'john',
File: event.target.files[0] //this has value here
const config = headers: 'content-type': 'multipart/form-data'
axios(
method: 'post',
url: '/api/upload',
data: data,
config
)
.then((response) =>
)
}).catch(err => console.log(err));
I can see the file when I console.log
, but when it gets to the api call, it is null
c# reactjs asp.net-web-api2 axios
add a comment |
When I make a call to web api 2 from axios, the HttpPostedFileaBase is coming in as null. I can't figure out what is wrong.
[HttpPost]
public IHttpActionResult Upload(Config config)
//config.Name has value
//config.File is null
Here is the axios call:
const data =
Name:'john',
File: event.target.files[0] //this has value here
const config = headers: 'content-type': 'multipart/form-data'
axios(
method: 'post',
url: '/api/upload',
data: data,
config
)
.then((response) =>
)
}).catch(err => console.log(err));
I can see the file when I console.log
, but when it gets to the api call, it is null
c# reactjs asp.net-web-api2 axios
When I make a call to web api 2 from axios, the HttpPostedFileaBase is coming in as null. I can't figure out what is wrong.
[HttpPost]
public IHttpActionResult Upload(Config config)
//config.Name has value
//config.File is null
Here is the axios call:
const data =
Name:'john',
File: event.target.files[0] //this has value here
const config = headers: 'content-type': 'multipart/form-data'
axios(
method: 'post',
url: '/api/upload',
data: data,
config
)
.then((response) =>
)
}).catch(err => console.log(err));
I can see the file when I console.log
, but when it gets to the api call, it is null
c# reactjs asp.net-web-api2 axios
c# reactjs asp.net-web-api2 axios
asked Mar 8 at 15:04
xaisoftxaisoft
1,29252152
1,29252152
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You should append your file to formdata.
const formData = new FormData();
formData.append('file',file)
then
axios(
method: 'post',
url: '/api/upload',
data: formData,
config
)
I was doing this before, but if I want to add other stuff from the form, do I have to doformData.append('form-prop','form-value')
for each one
– xaisoft
Mar 8 at 15:31
Yeah, but you can encapsulate them into one objectformData.append('body',)
– Georges Khater
Mar 8 at 15:40
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55065913%2fweb-api-2-call-from-axios%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should append your file to formdata.
const formData = new FormData();
formData.append('file',file)
then
axios(
method: 'post',
url: '/api/upload',
data: formData,
config
)
I was doing this before, but if I want to add other stuff from the form, do I have to doformData.append('form-prop','form-value')
for each one
– xaisoft
Mar 8 at 15:31
Yeah, but you can encapsulate them into one objectformData.append('body',)
– Georges Khater
Mar 8 at 15:40
add a comment |
You should append your file to formdata.
const formData = new FormData();
formData.append('file',file)
then
axios(
method: 'post',
url: '/api/upload',
data: formData,
config
)
I was doing this before, but if I want to add other stuff from the form, do I have to doformData.append('form-prop','form-value')
for each one
– xaisoft
Mar 8 at 15:31
Yeah, but you can encapsulate them into one objectformData.append('body',)
– Georges Khater
Mar 8 at 15:40
add a comment |
You should append your file to formdata.
const formData = new FormData();
formData.append('file',file)
then
axios(
method: 'post',
url: '/api/upload',
data: formData,
config
)
You should append your file to formdata.
const formData = new FormData();
formData.append('file',file)
then
axios(
method: 'post',
url: '/api/upload',
data: formData,
config
)
edited Mar 8 at 15:30
Marco
13.3k44780
13.3k44780
answered Mar 8 at 15:25
Georges KhaterGeorges Khater
643
643
I was doing this before, but if I want to add other stuff from the form, do I have to doformData.append('form-prop','form-value')
for each one
– xaisoft
Mar 8 at 15:31
Yeah, but you can encapsulate them into one objectformData.append('body',)
– Georges Khater
Mar 8 at 15:40
add a comment |
I was doing this before, but if I want to add other stuff from the form, do I have to doformData.append('form-prop','form-value')
for each one
– xaisoft
Mar 8 at 15:31
Yeah, but you can encapsulate them into one objectformData.append('body',)
– Georges Khater
Mar 8 at 15:40
I was doing this before, but if I want to add other stuff from the form, do I have to do
formData.append('form-prop','form-value')
for each one– xaisoft
Mar 8 at 15:31
I was doing this before, but if I want to add other stuff from the form, do I have to do
formData.append('form-prop','form-value')
for each one– xaisoft
Mar 8 at 15:31
Yeah, but you can encapsulate them into one object
formData.append('body',)
– Georges Khater
Mar 8 at 15:40
Yeah, but you can encapsulate them into one object
formData.append('body',)
– Georges Khater
Mar 8 at 15:40
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55065913%2fweb-api-2-call-from-axios%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown