I'm trying to request some data from a local python server using p5.js it works perfectly fine just when I tried to execute in the request I got this error:
Data expected to be returned: [['Test', "1002'\n"], ['Player1', "1002'\n"]]
Code:
function getdata(){
let url = "http://localhost:8080"
httpDo(
url,
{
method: 'GET',
headers: {'Access-Control-Allow-Origin': '*'},
haeder: {'Origin': 'http://localhost:8080'}
},
function(res){
print(res)
},
)
}
Related
My applications works fine when i run it by tns run ios, but when i try to debug it with tns debug ios it doesn't work well.
When i do an HTTP request to my back-end it won't be received in the back-end and an error wil occur.
"this.dispatchMessage is not a function. (In 'this.dispatchMessage', 'this.dispatchMessage' is undefined)"
This is the code i am using:
http.request({
url: config.baseUrl,
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
content: data
}).then(function (response) {
// Success
}, function (e) {
// error occur
});
I have this ajax POST code, which works directly on browser, but when i want to make a POST using the same data on Fiddler or SoapUI or using httpClient or HttpWebPost it doesn't work, always returns ERRROR. Below are the Ajax code and Fiddler. Thank you in advance.
$.ajax({
type: "POST",
url: "http://IP/address/post/something",
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
dataType: "text",
data:
{ message: 'testMessage', destination: '8888888888', campaign: 'UATTest', agent: 'TestingAgent'}
,
success: function (resp) {
if (resp != "ERROR") {
} else {
}
},
error: function (e) {
}
});
Update :
Does anybody know how to consume a REST API using FormParam ? how is it differ from JSON and XML ?
params:
#FormParam("destination"), #FormParam("message"), #FormParam("campaign"), #FormParam("agent")
We are new to angular js.
We tried http request using $http.get it is working fine. But in post request it is creating an issue, it comes to success and show bad parameter error code 103.
Same we have tried in ajax request using $.ajax({}), and it is working fine.
I have also paste my code.
Can anyone help us out?
mainApp.controller('registrationCtrl', function($scope, $location, $http) {
$scope.registration = function() {
console.log("registration called");
var ws_url = "http://apparelinindia.com/selfiestandoff/WebServices/register";
var request = $http({
method: "post",
url: ws_url,
data: {
user_email: $scope.email,
user_password: $scope.password
},
dataType: 'json',
headers: {
'Content-Type': 'application/json'
}
});
request.success(function(data) {
console.log("Success" + data);
});
request.error(function(error) {
console.log("Success" + JSON.stringify(error));
});
};
});
You can use http Post in following way:
var request = $http.post(ws_url, {
user_email: $scope.email,
user_password: $scope.password
});
The name of the http method should be written in uppercase. Also, the property datatype is not awaited by $http, you should remove it:
var request = $http({
method: "POST",
url: ws_url,
data: {
user_email: $scope.email,
user_password: $scope.password
},
headers: {
'Content-Type': 'application/json'
}
});
Note, in the above call to $http you are setting the header 'Content-Type': 'application/json'. But this header is automatically injected by $http (see $http documentation), therefore you can remove it, and use the short syntax:
var request = $http.post(ws_url, data);
with data equals to:
{
user_email: $scope.email,
user_password: $scope.password
}
Are You Getting this error ??
{"status":false,"error":{"code":"103","message":"Required Parameters not found"}}
If Yes, Its Not your Problem Contact the Web service provider.
Ask him to give the valid parameter
I have set up a proxy on Apache HTTP server for making the cross domain Ajax call. The call is happening but is returning a response indicating that the API key passed as a request header is invalid.
Can you make cross domain Ajax calls using Apache web server proxy? If so what am I doing wrong. ?
The proxy setting is as follows:
ProxyPass /api-temp/* http://api.temp.com/
The code to make the Ajax call is as follows:
var imageNamespace = {
imageUrls: [ ],
url: '/api-temp/v1/data/cat/42736286',
test: function() {
alert(234);
},
getImages: function() {
$.ajax({
type: 'GET',
dataType: 'json',
cache: true,
headers: {'API_KEY': 'xxxxxxxxxxxxxxxxxxxxxxxxx'},
url: imageNamespace.url,
success: function () {
alert('success:', success);
},
error: function (error) {
alert('ERROR:', error);
},
complete: function () {
alert('complete');
}
});
},
}
Here is the response in the browser:
The URL it is invoking is as follows: http://api.temp.com/v1/data/cat/42736286
Please enter valid API Key
I am passing the key in the request header but it is not being picked up. Any insight on how to resolve this will be helpful.
Below code is in my website:
function validateRequest() {
var $form = $('form');
if ($form.valid()) {
$.support.cors = true;
var lnkey = $('#txtloan').val();
var psw = $('#txtpsw').val();
var loanServiceUrl = #Html.Raw(Json.Encode(ConfigurationManager.AppSettings["LoanServiceURL"]));
var msg = {"loan": lnkey, "psw": psw};
$.ajax({
cache: false,
async: true,
type: "POST",
url: loanServiceUrl + "ValidateRequest",
data: JSON.stringify(msg),
contentType: "application/json; charset=utf-8",
dataType: "json", //jsonp?
success: function (response) {
$(response).each(function(i, item) {
if (item.Validated.toString().toUpperCase() == 'TRUE') {
// When validation passed
$('#divResult').load('#Url.Action("GetLoanInfo", "Validate")');
$("#btnClearStatus").show();
$('#btnGetStatus').hide();
}
});
},
error: function (errormsg) {
alert("ERROR! \n" + JSON.stringify(errormsg));
}
});
}
}
I have set following setting in IIS where my service is deployed.
When I make a POST call from website, I see two calls (probably one is pre-flight call for CORS) in fiddler. This is working fine in chrome and Safari but not in Firefox. I get HTTP 405 error. I am using Firefox 21.0.
Below is the snap shot from fiddler when service is called from firefox.