system error is null from GradesManagementService - desire2learn

In case of a system error from the GradesManagementService, the returned response object is null, but the response header includes the diagnostic information. What class do I use to get this information?
Here is my code:
GradesManagementServiceV10 port = service.getGradesManagementServiceV10();
GetGradeValuesByOrgUnitRequest r = new GetGradeValuesByOrgUnitRequest(); GetGradeValuesByOrgUnitResponse resp = new GetGradeValuesByOrgUnitResponse(); WSBindingProvider bp = (WSBindingProvider)port; bp.setOutboundHeaders( Headers.create(formatSOAPHeader())); ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, getUrl());
resp = port.getGradeValuesByOrgUnit(r); // the response is null. <------ How do I see what the error is?

In your service object (in the above code snippet that would be port, the object of the Web service proxy class GradesManagementServiceV10), ResponseHeader property would contain such information (this property's type is ResponseHeaderInfo).

If you are doing new development with Desire2Learn I would also suggest that you look at the Valence REST/JSON API. New features and new API calls are going to show up in that system http://docs.valence.desire2learn.com/ (it is always deployed, the docs are open, etc.)

Related

How to get oauth AccessToken in classic asp

I want to send email by connecting google via oauth
Below is the code present for C#
MailSender objMail = new MailSender();
objMail.TLS = true;
objMail.Username = "myaccount#gmail.com";
objMail.Password = "[oauth]ya29.Il-8B-88nf.......GhoNhUXKtBS-ZEQOAZ9tTWg";
...
objMail.Send();
For whole code please navigate to
https://www.aspemail.com/net_manual_03.html#3_5
To generate access token which is appended with "[oauth]" above, we are using
MailSender objMail = new MailSender();
MailSender objMail2 = objMail.GetAccessToken("GMAIL", "4/wQGBh....LtcM", false);
string AccessToken = objMail2.Username;
string RefreshToken = objMail2.Password;
int ExpiresIn = objMail2.Timeout;
I want to implement the same functionality in classic asp, but when i am creating object of "MailSender" in classic asp, it is throwing error that:
Object doesn't support this property or method:
'objMail.GetAccessToken'
Please suggest me how can i generate access token of oauth from classic asp
That error is telling you that the object you are using doesn’t recognise the method you are trying to call. In this situation the official documentation is the best resource.
Quote from GetAccessToken()
This method was introduced in version 5.5.0.1.
The likelihood here is you are using an older version of the ASPEmail COM component.
You can use the below code to output the version information;
<%
Dim Mail
Set Mail = Server.CreateObject("Persits.MailSender")
Call Response.Write("Version: " & Mail.Version)
%>

AuthFlow.CreateCredentialsFromVerifierCode throws error only on load balancer

I am using Tweetinvi for posting images to Twitter.
From our App servers its working fine to post to Twitter.
But, When tried from our load balancer getting this error -
Error:The credentials are required as the URL does not contain the
credentials identifier.
Stack Trace: at Tweetinvi.AuthFlow.CreateCredentialsFromVerifierCode(String
verifierCode, String authorizationId, IAuthenticationContext
authContext)
My code snippet is like this -
var verifierCode = Request.Params.Get("oauth_verifier");
var authorizationId = Request.Params.Get("authorization_id");
var userCreds = AuthFlow.CreateCredentialsFromVerifierCode(verifierCode, authorizationId);
I see these parameters(oauth_verifier, authorization_id,..) being passed to the callback page. But still seeing the above error in the call back page.
Note: this issue is only when I try posting to Twitter on our loadbalancer (using the individual servers working fine).
Should I use a different overloaded function?
So the problem comes from the fact that you are actually using a load balancer. But let me explain how the authentication works and how you can solve your problem.
var appCredentials = new ConsumerCredentials("", "");
var authContext = AuthFlow.InitAuthentication(appCredentials, "");
When you call AuthFlow.InitAuthentication, it returns an IAuthenticationContext. This context contains all the information required to process the callback from Twitter.
But in addition to this, Tweetinvi adds a parameter authorization_id to the callback so that it can map the callback request to an actual IAuthenticationContext.
var authorizationId = Request.Params.Get("authorization_id");
var userCreds = AuthFlow.CreateCredentialsFromVerifierCode(verifierCode, authorizationId);
When you call AuthFlow.CreateCredentialsFromVerifierCode with an authorization_id as a parameter it will look into the local dictionary and try to get the IAuthenticationContext.
Because you are using a load balancer, the server executing the AuthFlow.InitAuthentication can be different from the server your receiving the callback request.
Because your callback arrives at a different server, it actually result in the AuthenticationContext being null.
This is what I tried to explain in the documentation.
How to solve this?
What you need to do is to store the IAuthenticationContext information required for the CreateCredentialsFromVerifierCode to continue its work when it receives the callback. I would suggest you store this in your database.
When you receive your callback you will have to get back these information from your db. To do that I would suggest that when you initally call the `` you add to the callback url a parameter with the value storing the authentication id in your database (e.g. my_auth_db_id=42).
var authContext = AuthFlow.InitAuthentication(appCredentials, "http://mywebsite.com?my_auth_db_id=42");
When your callback arrives you will be able to do :
var myDBAuthId = Request.Params.Get("my_auth_db_id");
With this value you can now create a new token with the required information (stored in the db).
var token = new AuthenticationToken()
{
AuthorizationKey = "<from_db>",
AuthorizationSecret = "<from_db>",
ConsumerCredentials = creds
};
Now you are ready to complete the operation:
var userCreds = AuthFlow.CreateCredentialsFromVerifierCode(verifierCode, token );
I realize this is a big post, but I wanted to explain how it works.
Please let me know if anything does not makes sense.

ios swift 2.1 - unable to send Patch request with body

I'm trying to write a http rest client for my webservice and i need to send some PATCH requestes with data in the body.
I'm using the JUST library for sending requests ( https://github.com/JustHTTP/Just )
My express application just doesn't see the request.
Here's some code (i'm testing in playground, and everything went fine with other kind of requests like put, post...)
headers = ["accept":"application/json","content-type":"application/json","authorization":"key"] //key is ok
var data = ["id":3, "quantity":6]
var r = Just.patch("http://api.marketcloud.it/v0/carts/1233", headers:headers, data:data) //1233 is a cart Id
print(r)
print(r.json)
The method Just.patch returns an HTTPResult Object.
this says 'OPTIONS http://api.marketcloud.it/v0/carts/13234 200'
Also this object should contain a json, but it's 'nil'.
On the server-side, my express applications doesn't receive the request (it just logs an 'OPTION', but nothing else).
Could this be a playground-related problem? Or a just-related one?
Thanks for any suggestion
I managed to contact the library's author via twitter and he fixed the bug and answered me in less than 24h!
Here's the new release of the library.
https://github.com/JustHTTP/Just/releases

WSDL service reference giving error

I am using a doc data payments gateway service and when I try to give it a request to create an order it throws the following exception:
XmlSerializer attribute
System.Xml.Serialization.XmlAttributeAttribute is not valid in
version. Only XmlElement, XmlArray, XmlArrayItem, XmlAnyAttribute and
XmlAnyElement attributes are supported when IsWrapped is true.
I don't think it is an exception that has anything to do with the service. What am I doing wrong on my side of implementation. Can anyone help me with that?
EDIT
I have used DocDataPayments gateway and used the wsdl refrence they give to make the call.
The create call I am making is as follows:-
PaymentServiceSOAPClient client = new PaymentServiceSOAPClient();
createSuccess success = new createSuccess();
client.create(merchant, strMTID, paymentPreferences, menuPreferences, shopper, totalGrossAmount, billTo, "description", "Thanks for your purchase", true, new paymentRequest(), new invoice(), new technicalIntegrationInfo(), Convert.ToDecimal(0.9), out success);
I think, you are using wcf default serializer to make proxy classes.you can try with DataContract serializer instead default serializer.

Why is the Etrade API returning a missing parameters error?

I have successively obtained a request token, and am now using it in conjunction with my consumer key to create the following request
https://us.etrade.com/e/etws/authorize?key=2fc*******c323d6&token=IIrs6BsIrGQ********duC60GAmLq8
where the asterisks have been substituted for my consumer key and request token. I give this as an argument to getAuthorizeURL This returns an ETWSException and output in the terminal reading
ERROR OAuthClientImpl - Mandatory parameters missing
I have the two required arguments for the getAuthorizeURL method, and I am sure they are formatted correctly. Can anyone tell me what is going wrong here?
Also, if it helps to know, calling the getAuthorizeURL causes my default browser to open and brings me to the address that I entered above, but it returns a 404 error.
If you're using the sample code from the Docs.. they are missing 1 piece.
(java)
client = OAuthClientImpl.getInstance(); // Instantiate IOAUthClient
request = new ClientRequest(); // Instantiate ClientRequest
request.setEnv(Environment.SANDBOX); // Use sandbox environment
request.setConsumerKey(oauth_consumer_key); //Set consumer key
request.setConsumerSecret(oauth_consumer_secret); // Set consumer secret
token= client.getRequestToken(request); // Get request-token object
oauth_request_token = token.getToken(); // Get token string
oauth_request_token_secret = token.getSecret(); // Get token secret
request.setToken(oauth_request_token);
request.setTokenSecret(oauth_request_token_secret);
String authorizeURL = null;
authorizeURL = client.getAuthorizeUrl(request);
URI uri = new URI(authorizeURL);
Desktop desktop = Desktop.getDesktop();
desktop.browse(uri);
The Documentation sample forgot to mention, you'll need to set the Token Key/Secret on the Request object, before you make the call the get AuthorizeUri.
request.setToken(oauth_request_token);
request.setTokenSecret(oauth_request_token_secret);

Resources