how to create Appoinment from Android MS CRM SDK? - android

i am creating appointment using below code give "500 Internal Server Error"
i added all fields check it
Appointment objappointment = Appointment.build()
.setSubject("Android sub")
.setDescription("dis from device")
.setRegardingObjectId(new EntityReference("account", UUID.fromString("0717b8e2-d00a-e611-8115-c4346bdd11d1")))
.setOwnerId(new EntityReference("systemuser", UUID.fromString("3edb272d-2da7-4c89-9350-2f4bd4e1762b")))
.setStateCode(new OptionSetValue(0))
.setNew_Latitude(23.7845)
.setNew_Longitude(73.6574)
.setNew_City("Surat")
.setActualStart(mDate.getTime())
.setActualEnd(mDate1.getTime())
.setNew_ZipPostalCode("380060")
.setNew_Street1("Street1")
.setNew_Street2("Street3")
.setNew_street3("Street3")
.setNew_StateProvince("Gujarayt")
.setNew_CountryRegion("India")
.setNew_Latitude(23.7845)
.setNew_Longitude(73.6574)
.setStatusCode(new OptionSetValue(0))
.setPriorityCode(new OptionSetValue(2));
try {
RestOrganizationServiceProxy restService = new RestOrganizationServiceProxy(mOrgService);
restService.Create(objappointment,new Callback<UUID>() {
#Override
public void success(UUID uuid, Response response) {
log("sucess", uuid.toString());
}
#Override
public void failure(RetrofitError error) {
displayError(error.toString());
log("error", error.toString());
}
});
}
catch(Exception ex) {
displayError(ex.getMessage());
log("msg",ex.toString());
}
another entity create successfully using above code just got error in "Appoinment"

Could you get more details of the exception? 500 could be any exception. At least you know the request hit the server and it's failing on the CRM server side. Maybe a plugin or similar is raising the exception.
I think you have to pass the objectid to whom the annotation will be linked to (Account, Contact, or whatever...)
Is that on-premise or online CRM? If OnPremise you could enable includeExceptionDetailInFaults property in the web.config to at least get more details of the exception....

Related

JWS from Google SafetyNet contains different nonce value than one I submitted in attest()

I'm trying to implement SafetyNet in an Android app but am running into this issue:
The JWS that I receive show the nonce as a particular value, but it is different than the one I passed in here:
Task<SafetyNetApi.AttestationResponse> task = client.attest(nonce.getBytes(), apiKey);
task.addOnSuccessListener(this, new OnSuccessListener<SafetyNetApi.AttestationResponse>() {
#Override
public void onSuccess(SafetyNetApi.AttestationResponse attestationResponse) {
handleJWS(attestationResponse.getJwsResult());
}
}).addOnFailureListener(this, new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
if (BuildConfig.DEBUG)
Log.d("cts", "fail " + e.toString());
}
});
I use nonce.getBytes() as a parameter, as the nonce generated from the server is a String.
I've read the documentation over and over again, but can't figure out why the nonce value I receive as part of the JWS doesn't match the value I put in the attest() method. If this is expected, why is this so and how can I get the server to expect this value in order to verify it?
Any ideas?
Thanks!
I had the same issue and just figured out what was wrong: the nonce, apkDigestSha256 and the values of apkCertificateDigestSha256 are Base64 encoded! See https://github.com/googlesamples/android-play-safetynet/blob/master/server/java/src/main/java/AttestationStatement.java
In order to compare your nonce with the one from the JWS you have to do:
Arrays.equals(yourNonce, Base64.decode(attestationStatement.nonce(), Base64.DEFAULT))

Android: Parse Server save Error 111: This is an invalid Polygon

I'm trying to save a GeoPolygon into my Parse server using an android app but I keep getting an:
error 111: this is not a valid polygon
this is my code:
//create the parse object
ParseObject obj = new ParseObject("SomeClass");
List<ParseGeoPoint> geoPoints = new ArrayList<ParseGeoPoint>();
geoPoints.add(new ParseGeoPoint(1.468074, 110.429638));
geoPoints.add(new ParseGeoPoint(1.468075, 110.429287));
geoPoints.add(new ParseGeoPoint(1.467376, 110.429681));
geoPoints.add(new ParseGeoPoint(1.467373, 110.429283));
ParsePolygon geoPolygon = new ParsePolygon(geoPoints);
obj.put("Boundaries", geoPolygon);
obj.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
Toast.makeText(getContext(), "Geo Polygon save complete.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getContext(), "Geo Polygon save failed. error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
I followed the Docs for geopolygons here:
http://docs.parseplatform.org/android/guide/#parsepolygon
and somehow, even when I copy pasted the code provided in the docs, it doesnt work.
Any suggestions/ solutions are most welcomed.
I believe not many people may see this but I'll post my solution to this anyway.
The issue was solved after I updated the version of my Parse Server. I didn't note which version I updated the Parse Server from but my current Parse Server is now v2.7.1 .
Previous/ older version of Parse Server does not support geo-Polygons.

Working with azure mobile service in android

I am working on a project in which I have to work with Azure Back end, I have inserted data into the table, but don't know how to get its response and where should I use Json parsing .. below is my code .. please guide me about this
mClient.getTable(TodoItem.class).insert(item, new TableOperationCallback<TodoItem>() {
public void onCompleted(TodoItem entity, Exception exception, ServiceFilterResponse response) {
if (exception == null) {
// Insert succeeded
Toast.makeText(getApplicationContext(),"yes", Toast.LENGTH_LONG).show();
} else {
// Insert failed
String msg=exception.getCause().getMessage();
Toast.makeText(getApplicationContext(), "No", Toast.LENGTH_LONG).show();
}
}
});
For information on using the Android client SDK for Azure Mobile Apps, see the following articles:
Create an Android app
Enable offline sync for your Android mobile app
How to use the Android client library for Mobile Apps

Stripe android app connect to Node.js server

I'm working a project to integrate Stripe's payment service to my android app. I have the basic client code setup.
Card card = new Card("4242424242424242", 12, 2016, "123");
boolean validate = card.validateCard();
if (validate) {
try {
new Stripe(TEST_PUBLUSHABLE_KEY).createToken(card, new TokenCallback() {
#Override
public void onError(Exception e) {
System.out.println("ERROR");
}
#Override
public void onSuccess(Token token) {
System.out.println("SUCCESS");
}
});
} catch (AuthenticationException e) {
e.printStackTrace();
}
}
Now I need to setup a server, which I plan on using Node.js and Express. I followed their sample code on: https://stripe.com/docs/tutorials/charges
var express = require('express');
var bodyParser = require('body-parser');
var stripe = require('stripe')('sk_test_sGyqMsiFmf45xoZrDCy5ItcU'); // Test Secret Key
var app = express();
app.use(bodyParser());
app.post('/charge', function(req, res) {
var stripeToken = request.body.stripeToken;
var charge = stripe.charges.create({
amount: 1000, // amount in cents, again
currency: "cad",
card: stripeToken,
description: "payinguser#example.com"
},
function(err, charge) {
if (err && err.type === 'StripeCardError') {
console.log("The card has been declined");
}
});
});
app.use(express.static(__dirname + '/public'));
app.listen(3000);
I have never worked with servers, so I think I'm having trouble communicating between the android app and the server that is on my computer's localhost:3000.
According to Stripe's documentation, I need to have my server accept a HTTP POST call for the token, but I'm not quite sure how to do that.
Really appreciate your help.
Update #1:
Use Ultrahook to forward Stripe's POST to my localhost.
I use Node.js to setup my server, which receives all Stripe's requests and then get the information I need from the request body.
Still having trouble getting the onSuccess callback on Android to work, it always go to the onError callback.
Update #2:
Solved the onError callback error by printing the error message to console.
Permission denied (missing INTERNET permission?
Turns out I need to include this line to the AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
Link to the Stack Overflow post that solved this part of my problem:
What permission do I need to access Internet from an android application?

How do I get response from Azure Mobile Service to confirm sending?

i'm currently building a simple android app that sends info to Azure mobile services. I'm using the below example code of the tutorial.
mSClient = new MobileServiceClient(URL, KEY, context);
mSClient = getMSClient();
mSClient.getTable(MyClass.class).insert(form, new TableOperationCallback<MyClass>() {
public void onCompleted(MyClass entity, Exception exception, ServiceFilterResponse response) {
if (exception != null) {
Log.e("MSG", exception.getLocalizedMessage());
}
if (response != null) {
Log.e("MSG", response.getContent());
}
}
});
Now, how do I get the response from ServiceFilterResponse in onComplete method that takes a while to get and the MobileServiceClient have done its work already.
How do I wait to flag my info on sqlite as sent?
When the callback is invoked, it means that the insertion operation already finished at the server side. If you want to flag something between the moment you send the 'insert' request (which is basically a HTTP POST request) to the moment the operation is complete: right
mSClient = new MobileServiceClient(URL, KEY, context);
mSClient = getMSClient();
mSClient.getTable(MyClass.class).insert(form, new TableOperationCallback<MyClass>() {
public void onCompleted(MyClass entity, Exception exception, ServiceFilterResponse response) {
if (exception != null) {
// here: tell sqlite that the insert request failed
Log.e("MSG", exception.getLocalizedMessage());
} else {
// here: tell sqlite that the insert request succeeded
Log.e("MSG", response.getContent());
}
}
});
// here: tell sqlite that the insert request was sent

Categories

Resources