Angularjs cannot post big data by $http - angularjs

var data = $.param({
json: JSON.stringify(formData)
});
$http.post("/test", data).success(function(data, status) {
$scope.hello = data;
})
I tested it if the data is 32K, it will fail:
{
"data": null,
"status": 0,
"config": {
"method": "POST",
"transformRequest": [null],
"transformResponse": [null],
"url": "http://localhost:3000/test",
"headers": {
"Content-Type": "application/json",
"Accept": "application/json, text/plain, */*"
},
"data":....
and my test server which is a ruby server will not get any request.
How can I solve it?

Related

Commercejs PayPal checkout internal error

I am running into an internal error when trying to capture the checkout order with PayPal. When I run commerce.checkout.capture with paypal gateway and relevant details (payerId and paymentid) it throws a 500 internal error with this error message:
{
"message": "Unsuccessful response (500: ) received",
"statusCode": 500,
"statusText": "",
"data": {
"status_code": 500,
"error": {
"message": "There was an internal error. We have been notified.",
"type": "internal_error"
},
"id": "e231f6adc6e3469b95468b770ee2c5b1"
},
"originalError": {
"message": "Request failed with status code 500",
"name": "Error",
"stack": "Error: Request failed with status code 500\n at e.exports (https://www.alchemyremember.me/app-33ce862eff9a0d293497.js:2:27209)\n at e.exports (https://www.alchemyremember.me/app-33ce862eff9a0d293497.js:2:29644)\n at XMLHttpRequest.y (https://www.alchemyremember.me/app-33ce862eff9a0d293497.js:2:22514)",
"config": {
"url": "checkouts/chkt_gvRjwOGzeew4mN",
"method": "post",
"data": "{\"customer\":{\"firstname\":\"Matthew\",\"lastname\":\"Bloemetje\",\"email\":\"mattb007#gmail.com\"},\"payment\":{\"id\":\"gway_9l6LJmxJE8Oyo1\",\"gateway\":\"paypal\",\"paypal\":{\"action\":\"capture\",\"payment_id\":\"0YE34089FH8264019\",\"payer_id\":\"Q29FF5HGE63PG\"}}}",
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json",
"X-Authorization": "pk_47885dbdd0e55e008c1c4982d9e35fb2c99247830bdc9",
"X-Chec-Agent": "commerce.js/v2",
"Chec-Version": "2021-09-29"
},
"params": null,
"baseURL": "https://api.chec.io/v1/",
"transformRequest": [
null
],
"transformResponse": [
null
],
"timeout": 60000,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"maxBodyLength": -1,
"transitional": {
"silentJSONParsing": true,
"forcedJSONParsing": true,
"clarifyTimeoutError": false
}
}
}
}
I tried to capture the paypal checkout data with commerce.checkout.capture. Expected to return order data with success message and redirect to confirmation page of the order

Login token Axios post request gets Unauthorized response

I am encountering some difficulties while trying to update some data in a mysql database.
I am making an axios post request towards this api and inside the header I am sending the token that I receive from the backend after succesfull login.
I will show here the apiDocumentation and the POST req that I am making because I really don't understand how to send the login token to have authorization to the data.
Any help would very helpfull.
This is the backend apiDocumentation:
"post": {
"summary": "Post new data row",
"description": "Post new data row",
"parameters": [
{
"name": "token",
"in": "header",
"required": true,
"description": "token",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "string",
"example": "{\"test\":1}"
},
"type": {
"type": "string",
"example": "1"
},
"status": {
"type": "integer",
"example": 1
}
},
"required": [
"data",
"type"
]
}
}
}
},
This is my Post request that I am doing in my code:
case "newsTitle" :{
const {titlu} = this.state;
data = JSON.stringify(titlu);
const token = this.props.history.location.state.token;
const headers = {
//"token":token
"Authorization": token,
'Accept': '*/*',
//"Content-Type": "multipart/form-data"
"Content-Type":"application/json"
};
try {
const response = await axios.post(url, data, headers);
console.log("response::", response);
try this
case "newsTitle" :{
const {titlu} = this.state;
data = JSON.stringify(titlu);
const token = this.props.history.location.state.token;
const headers = {
//"token":token
'Authorization': `Bearer ${token}`
'Accept': '*/*',
//"Content-Type": "multipart/form-data"
"Content-Type":"application/json"
};
try {
const response = await axios.post(url, data, headers);
console.log("response::", response);

Refresh token endpoint not working correctly - AADSTS90033

Since the recent outage, getting refresh tokens seems to be broken, even though the status account says everything is back to normal. Any idea what could be causing this?
"response": {
"statusCode": 503,
"body": {
"error": "temporarily_unavailable",
"error_description": "AADSTS90033: A transient error has occurred. Please try again.\r\nTrace ID: 988f6bab-9fde-44c7-b480-a2dd07fd4900\r\nCorrelation ID: 031c9c04-389f-4b45-9b45-a1f4ee1b5d75\r\nTimestamp: 2020-09-28 22:41:10Z",
"error_codes": [90033],
"timestamp": "2020-09-28 22:41:10Z",
"trace_id": "988f6bab-9fde-44c7-b480-a2dd07fd4900",
"correlation_id": "031c9c04-389f-4b45-9b45-a1f4ee1b5d75"
},
"headers": {
"cache-control": "no-store, no-cache",
"pragma": "no-cache",
"content-type": "application/json; charset=utf-8",
"expires": "-1",
"strict-transport-security": "max-age=31536000; includeSubDomains",
"x-content-type-options": "nosniff",
"p3p": "CP=\"DSP CUR OTPi IND OTRi ONL FIN\"",
"x-ms-request-id": "988f6bab-9fde-44c7-b480-a2dd07fd4900",
"x-ms-ests-server": "2.1.11063.14 - WEULR2 ProdSlices",
"set-cookie": ["fpc=...; expires=Wed, 28-Oct-2020 22:41:10 GMT; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; httponly", "stsservicecookie=estsfd; path=/; secure; httponly"],
"date": "Mon, 28 Sep 2020 22:41:10 GMT",
"connection": "close",
"content-length": "424"
},
"request": {
"uri": {
"protocol": "https:",
"slashes": true,
"auth": null,
"host": "login.microsoftonline.com",
"port": 443,
"hostname": "login.microsoftonline.com",
"hash": null,
"search": null,
"query": null,
"pathname": "/common/oauth2/v2.0/token",
"path": "/common/oauth2/v2.0/token",
"href": "https://login.microsoftonline.com/common/oauth2/v2.0/token"
},
"method": "POST",
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"accept": "application/json",
"content-length": 1607
}
}
Getting access tokens seems to work..
This was part of the recent outage, please try again now. It has been resolved.

unauthorized with sendgrid smtp

I'm sending emails using sendgrid smtp and always get unauthorized error for the request.
I followed the docs here https://sendgrid.com/docs/for-developers/sending-email/api-getting-started/.
Should I login in from my terminal or something like this?
const sendFunc = () => {
return fetch('https://api.sendgrid.com/v3/mail/send', {
method: 'Post',
mode: 'no-cors',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {my apiKey-here}'
},
data: { "personalizations": [{ "to": [{ "email": "mahmoudnafea19#gmail.com", "name": "John Doe" }], "subject": "Hello, World!" }], "content": [{ "type": "text/plain", "value": "Heya!" }], "from": { "email": "mahmoud.m.elsayed19#gmail.com", "name": "Sam Smith" }, "reply_to": { "email": "sam.smith#example.com", "name": "Sam Smith" } }
}).then((response) => console.log(response)).catch((err) => console.log(err))
}
I had to pass the data and headers as objects outside the function call

Trying to post json in angularjs will 400 bad request

I am trying to post a static new entry using angularjs $http call but it will throws 400 bad request I am not getting why? Here I am passing the exact same type of json object in input.
Below is my main json file in which I want to add new record .
{
"count": 384,
"next": "http://104.197.128.152:8000/v1/tracks?page=2",
"previous": null,
"results": [
{
"id": 38,
"title": "Hey Jude",
"rating": "4.9",
"genres": [
{
"id": 5,
"name": "ramesh"
}
]
},
{
"id": 39,
"title": "hello adele",
"rating": "4.0",
"genres": [
{
"id": 4,
"name": "bollywood"
},
{
"id": 8,
"name": "metakai"
}
]
}
]
}
Data which I want to post:
var data = {
"id": 79,
"title": "new song anand",
"rating": "4.0",
"genres": [
{
"id": 4,
"name": "bollywood"
},
{
"id": 8,
"name": "metakai"
}
]
}
Syntax for posting data:
$http({
method: 'POST',
url: 'http://104.197.128.152:8000/v1/tracks',
dataType: 'json',
data: data,
headers: { 'Content-Type': 'application/json; charset=UTF-8' }
}).success(function (data) {
console.log(data,"success");
}).error(function (data) {
console.log(data,"fail");
});
Remove dataType: 'json' and charset=UTF-8 from headers.
$http({
method: 'POST',
url: 'http://104.197.128.152:8000/v1/tracks',
data: data,
headers: { 'Content-Type': 'application/json'}
}).success(function (data) {
console.log(data,"success");
}).error(function (data) {
console.log(data,"fail");
});
It must work .
And if not re-check your JSON format. Something must be missing.

Resources