According to this question:
Angular5 HttpClient send data but server can not understand its params
I send username, password and _token parameters to server through FormData in angular5. I set header to
'Content-Type': 'application/x-www-form-urlencoded'
now, I faced another problem in server.
Request header changed to
------WebKitFormBoundaryGOu5izF9uMKIXDW1
Content-Disposition: form-data; name:"username"
a#a.com
------WebKitFormBoundaryGOu5izF9uMKIXDW1
Content-Disposition: form-data; name="password"
123456
------WebKitFormBoundaryGOu5izF9uMKIXDW1
Content-Disposition: form-data; name="_token"
[object Object]
------WebKitFormBoundaryGOu5izF9uMKIXDW1--
Now, Laravel could not read request parameters in this way:
$request->input('username') // returns null
$request->input() // returns whole request content, not an object or array
How could I read request parameters ?
e.g. Is there any regular expression that can help me? or any patches in higher Laravel versions that I can use?
Laravel version: 5.2
Does your controller in Laravel have these included?
use Illuminate\Http\Request;
use Illuminate\Http\Response;
and does your function look like this?
public function signIn(Request $request, Response $response){
$output = $request->input('username');
return $output;
}
What we are doing above is getting the output of the response which we are wanting username and return that so you should get the username back
EDIT
Does your Angular service look like this
login(username:string, password:string) {
let formData = new FormData();
formData.append('username', username);
formData.append('password', password);
return this._http.post(
'http://oauth-api/api/me/signin',
formData
);
}
Related
I'm sending a put/patch request to backend (Inertiajs to Laravel). but the parameter bag is empty and all the inputs shows up in content attribute of request object.
// in frontend [Inertiajs]
form.patch(route('posts.update', props.post.id), options);
// form.put(route('posts.update', props.post.id), options); // same as patch method
// in backend Laravel
dd(request());
result:
Illuminate\Http\Request :
request:
parameters: []
content:
------WebKitFormBoundaryLAUcPkq3YTjgwsCM
Content-Disposition: form-data; name="title"
"some title"
now dd(request('title')) give me null.
what should I do to the code for sending the inputs through request parameters?
There is some multipart limitations. As Inertia says here, uploading files using a multipart/form-data request is not natively supported in some languages for the put, patch or delete methods. The workaround here is to simply upload files using post instead.
In your case, would look something like this:
form.post(route('posts.update', {
_method: 'put',
postId: props.post.id,
})
* Do it like this if you want to preserve the scroll:
form.post(route('posts.update', {
_method: 'put',
postId: props.post.id,
}, {
preserveScroll: true,
})
Using Postman I'm able to POST my refreshToken:
.
In my controller I can receive above token like so:
$request->header('refreshToken');
If I try to do the same using axios I receive the data in $request->refreshToken not in header
axios.post(
'mybackend/refreshToken',
{ 'refreshToken': myToken }
)
tried the 'headers' option in axios but no luck.
$request->header('refreshToken'); // I should receive the token here, from axios
I think you are sending the refreshToken in the body instead of the header.
It should be:
axios.post(
'mybackend/refreshToken',
{}, //body
{headers:{ 'refreshToken': myToken }} //header
)
I'm trying to upload a xlsx file to server, but I receive two different errors, whether I specify the contentType in the http request header or not. If I specify "Content-type: multipart/form-data" I get the following error:
FileUploadException: the request was rejected because no multipart
boundary was found
Then, if I do not specify the content type (as proposed in different answers), I get this error:
current request is not a multipart request
This is what I do to upload the file. HTML (input fired by a button that calls an uploadFile() method):
<input type="file" #fileUpload id="fileUpload" name="fileUpload" accept=".xlsx" style="display:none;" />
.ts:
uploadFile() {
const fileUpload = this.fileUpload.nativeElement;
fileUpload.onchange = () => {
this.file = fileUpload.files[0];
this.uploadFileToServer();
};
fileUpload.click();
}
uploadFileToServer() {
const formData = new FormData();
formData.append('file', this.file);
this.importService.uploadFile(formData).subscribe(d => {
});
}
In the service the method does this:
this.http.post(
apiUrl,
formData,
options
);
where in options there are the specified headers:
let applicationHeaders = new HttpHeaders();
applicationHeaders = applicationHeaders.append('Content-type', 'multipart/form-data');
multipart or blank.
In the POST request in the request payload I have:
------WebKitFormBoundarytNckytdr7I8wQcuc
Content-Disposition: form-data; name="file"; filename="Template (2).xlsx"
Content-Type: application/octet-stream
------WebKitFormBoundarytNckytdr7I8wQcuc--
Vue.js HTTP call
methods :{
login(){
var data ={
client_id: 2,
client_secret: '5YVQ6rsSehoh5BOWsxAU3KxGeqT1tCRGHn5dx1iX',
grant_type: 'password',
username : this.email,
password: this.password
}
//send a GET request using Vue-Resource
this.$http.get("http://localhost/kubikt2/public/api/login", data)
.then(response=>{
console.log(response)
})
}
}
Laravel
Route::get('api/login',function(Illuminate\Http\Request $req){
$arr["echo"]=$req->all();
$arr["test"]="OK!!";
return json_encode($arr);
}
As you can see, echo $req->getContent(); return nothing in Laravel.
check this out
How do I access the var data sent by Vue.js in Laravel ?
$req->all() is empty because no data is passed!
A GET request only evaluates data passed as query-string in the URI. It acts like the data parameter is null.
You could send your data as query (like "localhost/kubikt2/public/api/login?email"+email+"&someMore"+someMore) or use a POST request (which would be the better option here)
I am trying to post an image using the source parameter (Multipart/form-data) in the Graph API explorer. My source parameter looks like this:
{Content-Type: multipart/form-data; boundary=xxxsrixxx
--xxxsrixxx
Content-Disposition: attachment; filename=try2.gif
Content-Type: image/gif
Content-Transfer-Encoding: binary,base64
R0lGODlhXgExAYeAAQAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/fzL/oICAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKiouLi4yMjI2NjY6Ojo+Pj5CQkJGRkZKSkpOTk5SUlJWVlZaWlpeXl5iYmJmZmZqampubm5ycnJ2dnZ6enp+fn6CgoKGhoaKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq6ysrK2tra6urq+vr7CwsLG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DBOoII4yHciV0QvKmy4aeWDAc7YtUW9201X/Sf3YeqEJxvoVEFvZJuHCjlPX250vrusYgwAKwlAEyksCxHAFUpAFMBCyAFIGMYAFkHAJj6COLwE8RMAgOs3deCFcDUgQPuwAfGAIODE7jtAKflAUdkvd7qKJA556ShHRGaMCkTAKclAUCvDZRbGXjPHh6QIFRuAEnCHGVpGYS8GrBiMGffAFbtAGTbCtiUxY1RIAZSCPlTECquAMXRAIuNAHiHDRSxEH/AIDMkMqVe0YSTgsALguBtECu6YtuvopRXDh1XJQVI4Q1mAHfzAECtAApPcAKCAGoU11XxFpldGvvRGnX94RYIIIwHCrXD4szzvn/VHcfG4d7vK1fy4feeI96NqB48OSn4ZeHgSVLku06OwhLyMH6eZR6JQOHdd06evh55oeHJze6bpRLlYhqqD+Heq8I3ta6uUhDC1wA6H5kKq+HoLAARKACLaQDDDwMLG+67ze677+68Ae7MI+7MRe7MZ+7Mie7Mq+7Mze7M7+7NAe7dKOKAAAIf8LUElBTllHSUYxLjAWSW1hZ2UgZnJvbSBjbGlwYm9hcmQBIAA7
--xxxsrixxx--}
This always seems to return
{
"error": {
"message": "(#324) Requires upload file",
"type": "OAuthException",
"code": 324
}
}
Few questions:
Does facebook source parameter accept base64 encoded image data?
Has anyone tried using the source parameter in the graph api explorer and have a working sample?
should the source param value should be url-encoded?
Note: My access token has all the required permissions and if i am not wrong, my encoding seems to be wrong. The base64 encoded text above is a complete image and i could decode it and get the image.
Ok. This is going to sound crazy. After a week of trying I was able to post an image successfully to the facebook wall. The fix was to send the raw binary data as it is (no base64 encoding - fb does not like it) and make sure your multipart/form-data is correct. For instance, if you boundary is defined as "boundary=--xxxsrixxx" your actual request should look like this "----xxxsrixxx\r\nContent-Disposition......\r\n----xxxsrixxx"
This works fine for me, it only uses native JavaScript features and a file input:
const fileReader = new FileReader();
const file = document.getElementById('imageInput').files[0];
fileReader.onloadend = async () => {
const photoData = new Blob([fileReader.result], {type: 'image/jpg'});
const formData = new FormData();
formData.append('access_token', pageAccessToken);
formData.append('source', photoData);
formData.append('message', 'some status message');
let response = await fetch(`https://graph.facebook.com/${pageId}/photos`, {
body: formData,
method: 'post'
});
response = await response.json();
console.log(response);
};
fileReader.readAsArrayBuffer(file);
More information: http://www.devils-heaven.com/facebook-javascript-sdk-photo-upload-with-formdata/