I have problem when my cordova apps try to call the procedure in adapter, the adapter doesn't return the response.
The response of adapter is just like this :
errorMsg: "OK"
invocationContext: null
responseHeaders:
cache-control: "no-cache"
connection: "close"
content-type: "text/html; charset=UTF-8"
expires: "0"
pragma: "no-cache"
__proto__: Object
responseText: "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=utf-8"/><title>Error</title></head><body><H2>Error</H2><table summary="Error" border="0" bgcolor="#FEEE7A" cellpadding="0" cellspacing="0" width="400"><tr><td><table summary="Error" border="0" cellpadding="3" cellspacing="1"><tr valign="top" bgcolor="#FBFFDF" align="left"><td><STRONG>Error</STRONG></td></tr><tr valign="top" bgcolor="#FFFFFF"><td>This page can't be displayed. Contact support for additional information.<br/>The incident ID is: N/A.</td></tr></table></td></tr></table></body></html>"
status: 200
I have no idea whats the problem is. Please Help to solve this.
Update:
This is payload that I send into adapter (REST)
{
"id": "xxx",
"userID": "ANDxxx",
"firstName": "ANDY",
"lastName": "JOHNSON",
.............
}
Notes :
- I use mobile first 8.0.0.00-20180504-092633 version
- I think it's intermittent. Because just some data in payload that I sent into adapter that return no response
Related
I contacted my SMS company and asked them about API to send SMS by programming language.
they send the following code, but i didn't know how to use it in my vb.net application:
By this method can send message to one contact or multi contacts
Request:
POST http://api.yamamah.com/SendSMS
Host: api.yamamah.com
Content-Type: application/json
Body:
{
"Username": "",
"Password": "",
"Tagname": "",
"RecepientNumber": "05xxxxxx;05xxxxxx",
"VariableList": "",
"ReplacementList": "",
"Message": "test",
"SendDateTime": 0,
"EnableDR": False
}
Response
Status Code: 200
Content-Length: 70
Content-Type: application/json; charset=utf-8
Date: Sun, 26 Jan 2014 10:59:40 GMT
Returned message
{
"InvalidMSISDN": null,
"MessageID": "1d7d8d99-2da4-478a-8391-6783f467f479",
"Status": 1,
"StatusDescription": "Success"
}
Research how to consume a REST webservice in vb.net application.
Your SMS company has shared the below details
URL of the webservice: http://api.yamamah.com/SendSMS
HTTPS method: POST
Content-Type: application/json
message body in JSON format.
You can send the messages to multiple contacts as the Recepient Number is semicolon separated. ("RecepientNumber": "05xxxxxx;05xxxxxx",)
Do not use this provider API because it's not safe. Based on your sample, I can coclude that they're not using SSL/TLS for API calls and your password can be easily stolen by anyone between your computer and their server. Ask their support for a safer way of communicating.
Or you can look at our API which is also HTTP REST API. You can study how to send HTTP requests with JSON payload from VB.NET over here.
Then it might be useful to follow our tutorial on sending single sms.
And then check out bulk sms API call and it's compact form to send many sms like that:
POST https://api.wavecell.com/sms/v1/{subAccountId}/many/compact
Host: api.wavecell.com
Content-Type: application/json
Body:
{
"destinations": [
"6598760000",
"+659870001",
"tel+659870002",
"+33(509)758-000"
],
"template": {
"source": "BRAND",
"text": "Your message for all clients"
}
}
We moved to a new server and my Thinktecture IdentityModel stuff broke.
Here's a super simplified repro sample. This works run locally from Visual Studio, but deployed to the server the handler is clearly not handling.
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Thinktecture.IdentityModel.Tokens.Http;
namespace WebApplication1
{
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configuration.MessageHandlers.Add(
new AuthenticationHandler(CreateConfiguration()));
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
private AuthenticationConfiguration CreateConfiguration()
{
var config = new AuthenticationConfiguration
{
EnableSessionToken = true,
RequireSsl = false,
SendWwwAuthenticateResponseHeaders = false
};
config.AddBasicAuthentication(
(username, password) => { return username == password; });
return config;
}
}
}
The handler is not executing. I have set up remote debugging and this revealed that
The Thinktecture assembly is loaded
Application_Start creates and adds a basic auth handler
This script is the test client
<script>
$(document).ready(function () {
var u = "bilbo";
var p = "bilbo";
var btoken = btoa(u + ":" + p);
$.ajax({
url: "api/token",
headers: { Authorization: "Basic " + btoken },
}).then(function (result) {
document.write("auth ok");
}).fail(function (error) {
document.write("auth fail");
});
});
</script>
It produces a request for api/token decorated with a basic auth header as shown:
GET http://assa.com.au/api/token HTTP/1.1
Accept: */*
Authorization: Basic YmlsYm86YmlsYm8=
X-Requested-With: XMLHttpRequest
Referer: http://assa.com.au/sandpit
Accept-Language: en-AU,en-GB;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: assa.com.au
Connection: Keep-Alive
This server responds with this 401
HTTP/1.1 401 Unauthorized
Content-Type: text/html
Server: Microsoft-IIS/8.5
WWW-Authenticate: Basic realm="assa.com.au"
X-Powered-By: ASP.NET
Date: Wed, 17 Feb 2016 01:36:27 GMT
Content-Length: 1293
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>401 - Unauthorized: Access is denied due to invalid credentials.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
<h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
</fieldset></div>
</div>
</body>
</html>
Visual Studio 2013 is showing valid breakpoints in the handler but they are not hit. This is why I believe the handler is not being invoked.
The response specifies a realm, but modifying handler registration to specify realm = "assa.com.au" did not affect the outcome.
The answer lies in the handling of the absence of trailing slashes.
The test page is requested as assa.com.au/sandpit which does return the right HTML.
Close inspection of the 401 response reveals that the request is for api/token which is not the correct URL for the token dispenser - it should be sandpit/api/token
Requesting the test page as assa.com.au/sandpit/ causes the requested URL to become sandpit/api/token and everything comes out in the wash.
But why is it 401? Shouldn't it be 404 not found? It turns out that the webserver was configured to respond to unauthorised requests by asking the user agent to authenticate, expressed as a 401 auth demand.
The incorrect URL left things in an unauthorised state, producing a 401 auth demand.
This is the request I am posting
POST /3/image HTTP/1.1
Host: api.imgur.com
Authorization: Client-ID <My client ID>
Cache-Control: no-cache
----WebKitFormBoundaryE19zNvXGzXaLvS5C
Content-Disposition: form-data; name="image"
http://png1.findicons.com/files/icons/1580/devine_icons_part_2/128/home.png
----WebKitFormBoundaryE19zNvXGzXaLvS5C
However, the response I get is:
{
"data": {
"error": "Imgur is over capacity. Please try again.",
"request": "/3/image",
"method": "POST"
},
"success": false,
"status": 1203
}
I just want to use anonymous upload but the documentation is saying limit of 10MB right? anything I have done wrongly? what should I do to fix this error?
Imgur is frequently over capacity, so perhaps you can try again later. I doubt it's a problem on your end.
I have read other posts here and it looks like most of the time this boils down to fetch being async. I don't think that is my problem because 1. I test the results in the success callback of fetch and 2. I can console.log(model.toJSON()) in the js console later and it still is not updated
Notes: I am getting a good json response from the API and I can get the data by putting 'parse' in my model declaration like so
parse: function(data){
alert(data.screenname);
}
Here is my code, why is the model not being updated with the fetch call
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="vendor/components/underscore/underscore-min.js"></script>
<script src="vendor/components/backbone/backbone-min.js"></script>
</head>
<body>
Hello
<script>
$.ajaxSetup({
beforeSend: function(xhr){
xhr.setRequestHeader("Authorization", "Basic " + window.btoa("username" + ":" + "password"));
}
});
var User=Backbone.Model.extend({
parse: function(data){
alert(data.screenname);
},
urlRoot: 'http://api.myapi.com/user'
});
var user=new User({id:'1'});
user.fetch({
success: function(collection, response, options){
console.log(response);
console.log(user.toJSON());
}
});
</script>
</body>
</html>
When I log response, it show a good json coming back, but user.toJSON just shows the id as 1.
I can use parse in the model declaration to manually assign each value in the model from the response, but that seems like a dumb way to do it. I was under the impression that fetch() was supposed to populate the model with the result from the server.
**UPDATED**
Here is the response I get back from the server
{"id":1,"email":"test#email.com","password":"pass","screenname":"myname","id_zipcode":1,"id_city":1,"date_created":"2014-12-25 12:12:12"}
Here are the response headers from my api
HTTP/1.1 200 OK
Date: Tue, 04 Feb 2014 18:31:41 GMT
Server: Apache/2.2.24 (Unix) DAV/2 PHP/5.5.6 mod_ssl/2.2.24 OpenSSL/0.9.8y
X-Powered-By: PHP/5.5.6
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Authorization, Origin, X-Requested-With, Content-Type, Accept
Set-Cookie: PHPSESSID=pj1hm0c2ubgaerht3i5losga4; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 139
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: application/json; charset=utf-8
You have overridden your parse() method to effectively do nothing. It should return all the attributes to set on your model; you have not returned anything, hence, nothing was being set on the model.
It should look like this.
var User=Backbone.Model.extend({
parse: function(data){
alert(data.screenname);
return data; //all attributes in data will be set on the model
},
urlRoot: 'http://api.myapi.com/user'
});
While using Rails ActionMailer with Multipart Emails I created both:
approve_trade_email.html.erb
AND
approve_trade_email.text.erb
I do receive a well HTML formatted email in my Mail client (Mac OSX) but when checking my Gmail account for the same email I got an empty body with a noname attachement with the multiparts inside?
Help?
Why do I get this in Gmail?
thx
Joel
HERE THE NONAME ATTACHEMENT IN GMAIL:
----==_mimepart_4eab3a61bb3a8_10583ff27b4e363c43018
Date: Sat, 29 Oct 2011 01:27:29 +0200
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Content-ID: <4eab3a61bc857_10583ff27b4e363c43191#joel-maranhaos-macbook-pro.local.mail>
Do not to forget to make a donation on our Site: /home/index?path_only=false
----==_mimepart_4eab3a61bb3a8_10583ff27b4e363c43018
Date: Sat, 29 Oct 2011 01:27:29 +0200
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Content-ID: <4eab3a61bd5fa_10583ff27b4e363c432cb#joel-maranhaos-macbook-pro.local.mail>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link href="/assets/powerplants.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body id="email">
<p><b>Do not to forget to make a donation on our Site.</b></p>
</body>
</html>
----==_mimepart_4eab3a61bb3a8_10583ff27b4e363c43018--
I got the same problem and found the solution:
It's a bug in the old ActionMailer API of Rails 3, which does not include the multipart boundary definition in mail header.
see: https://github.com/rails/rails/pull/3090
You just have to use the new API (using the mail method)
class UserMailer < ActionMailer::Base
default :from => "notifications#example.com"
def welcome_email(user)
#user = user
#url = "http://example.com/login"
mail(:to => user.email, :subject => "Welcome to My Awesome Site")
end
end