When I call 'https://apisandbox-api.zuora.com/rest/v1/accounts' with required apiAccessKeyId, apiSecretAccessKey and parameters, I recieve the response
{
"success": false,
"reasons": [
{
"code": 90000011,
"message": "this resource is protected, please sign in first"
}
]
}
Not clear what is exact issue.
You need to call the connection api first in order to access any object in the Zuora sandbox.
Request URL
GET: https://apisandbox-api.zuora.com/rest/v1/connections
and the response you would see:
{
"success": true
}
Give it a try after calling this Api. It should be resolved then.Thanks.
You need to sign in first, there is an example in the Zuora SDK using a ConnectionManager source :
final ZClient Z_CLIENT = new ZClient();
final ConnectionManager cm = new ConnectionManager();
if (!cm.isConnected(Z_CLIENT, (String) ZConfig.getInstance().getVal("default.tenant.user.id"),
(String) ZConfig.getInstance().getVal("default.tenant.password")))
{
throw new RuntimeException("Couln't open a connection to Zuora API !");
}
Related
I'm working with the Google Analytics API for the first time and I'm trying to create a new property. I wrote a JS function in Google App Script:
function insertProperty() {
var resource =
{
// "accountId": "177832616",
"resource":{
"name": "Test Property 7",
// "dataRetentionResetOnNewActivity": false,
"websiteUrl": "https://www.test.com"
}
}
var accountID = '177832616';
var request = Analytics.Management.Webproperties.insert(resource, accountID);
// request.execute(function (response) { console.log(property.id) });
}
This is the error the API throws:
GoogleJsonResponseException: API call to analytics.management.webproperties.insert failed with error: Field name is required. (line 56, file "Code")
The insert() method seems to take two parameters: insert(Webproperty resource, string accountId);
Since it's not recognizing the name key/value I added to resource, my guess is I haven't declared the variable as a Webproperty type and I'm not sure how to do this. I assumed Webproperty was a { } variable type, but at this point I'm not sure what to try next. Doing research online, I'm not able to find anything regarding the API's Webproperty so any context/info is helpful.
From your question, I could understand that Google Analytics API is used with Advanced Google services of Google Apps Script. In this case, resource of Analytics.Management.Webproperties.insert(resource, accountId) can directly use the request body of the method of "Web Properties: insert". I think that the reason of your error is due to this. So please modify as follows and test it again.
From:
var resource =
{
// "accountId": "177832616",
"resource":{
"name": "Test Property 7",
// "dataRetentionResetOnNewActivity": false,
"websiteUrl": "https://www.test.com"
}
}
To:
var resource = {
"name": "Test Property 7",
"websiteUrl": "https://www.test.com"
}
Note:
When accountId is not correct, an error occurs. Please be careful this.
From iansedano's comment, in this case, request of var request = Analytics.Management.Webproperties.insert(resource, accountID); directly returns the values. So you can see the value like console.log(request) and console.log(request.toString()).
Reference:
Web Properties: insert
following post request give an error when creating a subscription for the Sent Items folder using Microsoft Graph
var apiUrl = "https://graph.microsoft.com/v1.0/subscriptions";
Request
{
"resource": "me/mailFolders('Sent Items')/messages",
"changeType": "created,updated,deleted",
"clientState": "320a6f10-9c62-4e59-a395-8cd27941b597",
"notificationUrl": "https://webhook.site/aaaa-6f49-4906-aaaa-e911f9391695",
"expirationDateTime": "2018-08-28T12:53:41.4830081+00:00"
}
Error Response
{
"error": {
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: BadRequest; Reason: Bad Request]",
"innerError": {
"request-id": "359f51a6-5b12-41f6-8a02-a68ba4c10585",
"date": "2018-08-27T06:42:18"
}
}
}
Unfortunately the webhook.site test site that you are using does not implement the validation token protocol that is required to setup a subscription. The webhook must return the value of the validationToken query parameter in the response body for the subscription to be created correctly.
i changed the resource property value for folder name 'Sent Items' to 'SentItems' . here is the working request
{
"resource": "me/mailFolders('SentItems')/messages",
"changeType": "created,updated,deleted",
"clientState": "320a6f10-9c62-4e59-a395-8cd27941b597",
"notificationUrl": "https://webhook.site/aaaa-6f49-4906-aaaa-e911f9391695",
"expirationDateTime": "2018-08-29T12:53:41.4830081+00:00"
}
I follow the tutorial here https://developer.chrome.com/apps/app_identity and use the api here https://developer.chrome.com/apps/identity but with no luck. Could anyone point out is anything wrong in this code?
function onGoogleLibraryLoaded() {
var redirect_uri = chrome.identity.getRedirectURL("http://qqibrow.github.io");
var full_url = "https://stackexchange.com/oauth/dialog?client_id=4716&redirect_uri=" + redirect_uri;
console.log(redirect_uri);
console.log(full_url);
chrome.identity.launchWebAuthFlow({
'url': full_url,
'interactive': true
}, authorizationCallback);
}
var authorizationCallback = function (data) {
// should print out redirect_uri with auth_token if succeed.
console.log(data);
};
// manifest.json
// ...
"permissions": [
"activeTab",
"identity",
"https://ajax.googleapis.com/",
"https://stackexchange.com/*",
"https://stackexchange.com/oauth/*",
"http://qqibrow.github.io/*"
],
"web_accessible_resources": [
"http://qqibrow.github.io/*",
"https://stackexchange.com/*",
],
// ...
If i try https://stackexchange.com/oauth/dialog?client_id=4716&redirect_uri=http://qqibrow.github.io it does work. But with above code, I always got a error page from stackexchange, saying that:
Application Login Failure error description: Cannot return to provided redirect_uri.
This is a creative usage of chrome.identity.getRedirectURL().
It does not allow you to redirect to an arbitrary domain; you can provide a path, but the domain for chrome.identity will be https://<app-id>.chromiumapp.org.
So, your call returns https://<app-id>.chromiumapp.org/http://qqibrow.github.io which is not a valid URL, and your auth fails.
I recommend re-reading the launchWebAuthFlow documentation.
I've started sending mails through Laravel (4.2) and its embedded Mandrill driver these days, but I need to catch Mandrill's response somehow.
Here's the code I use to send the message:
Mail::queue('emails.customerspromo', array('messaggio'=>$content, 'disclaimer'=>$disclaimer, 'user_email'=>$to, 'user_id'=>$uid), function($message) use ($sender, $to, $subject) {
$message->from('my#address.it', $sender);
$message->to($to);
$message->subject($subject);
$message->setCharset('UTF-8');
$message->getHeaders()->addTextHeader('X-MC-GoogleAnalytics', 'www.my-site.it');
$message->getHeaders()->addTextHeader('X-MC-GoogleAnalyticsCampaign', 'my-campaign');
});
What I need to intercept is Mandrill's JSON response, for example:
[
{
"email": "destination#address.com",
"status": "sent",
"_id": "80e1ca49d3ed4cbb9d9a3d932c0a14f8",
"reject_reason": null
}
]
How can I do that using Laravel's integrated drivers for Mandrill?
I could use Mail::send instead of Mail::queue, if it's necessary to interpret the response in real time.
Put a variable before your mail function like this:
$response = Mail::queue('emails.customerspromo', array('messaggio'=>$content, 'disclaimer'=>$disclaimer, 'user_email'=>$to, 'user_id'=>$uid), function($message) use ($sender, $to, $subject) {
$message->from('my#address.it', $sender);
$message->to($to);
$message->subject($subject);
$message->setCharset('UTF-8');
$message->getHeaders()->addTextHeader('X-MC-GoogleAnalytics', 'www.my-site.it');
$message->getHeaders()->addTextHeader('X-MC-GoogleAnalyticsCampaign', 'my-campaign');
});
It will still work but now you can see the response from mandrill.
According to Facebook documentation, age_range is a default property when requesting user data:
https://developers.facebook.com/docs/facebook-login/permissions#reference-basic-info
This does work when I use "me" as the user-id with the proper token:
https://graph.facebook.com/me?fields=id%2Cname%2Cemail%2Cfirst_name%2Clast_name%2Cusername%2Cgender%2Cpicture%2Cage_range&format=json&access_token=[accessToken for required user]
{
"id": "FACEBOOKID",
"name": "testuser",
"email": "testuser\u0040test.net",
"first_name": "testuser",
"last_name": "testuser",
"gender": "male",
"age_range": {
"min": 21
},
"picture": {
"data": {
"url": "https://...",
"is_silhouette": false
}
}
}
But the data_range is then empty when I use the user id:
https://graph.facebook.com/[FacebookId]?fields=id%2Cname%2Cemail%2Cfirst_name%2Clast_name%2Cusername%2Cgender%2Cpicture%2Cage_range&format=json&access_token=[AccessToken]*
Gives me back:
{
"id": "FACEBOOKID",
"name": "testuser",
"email": "testuser\u0040test.net",
"first_name": "tftestuser",
"last_name": "tftestuser",
"gender": "male",
"picture": {
"data": {
"url": "http://....",
"is_silhouette": true
}
}
}
Any idea why? What am I missing here?
Thank you in advance!
I found an answer using the API here:
no age_range in facebook response (javascript sdk)
The api call "/me" returns the default info, which doesn't always include age_range.
However you can request age_range with the api call:
"/me?fields=age_range"
According to Platform Updates: Operation Developer Love -
accessible for all users that install your app
So age_range won't be returned if the user hasn't installed your app. As in your case, that user might not be using the app for which you are getting this blank.
Also the purpose of age_range field is to let your app determine whether your app can provide some age-sensitive contents. So, retrieving age_range for user's friends is inappropriate and you'll have to get friends_birthday permission.
EDIT:
The link also says-
mobile apps and websites that use Facebook Login to restrict their content to people age 18+ and 21+
That means this field is available only for the apps who have restricted their content to people age 18+ and 21+- please check!
I too spent hours on trying to find a solution for this.
Am sharing my experience below:
I initially asks for an fb session by asking for user details with the following permissions:
session.openForRead(new com.facebook.Session.OpenRequest(
LoginActivity2.this).setPermissions(
Arrays.asList("public_profile","email")).setCallback(
statusCallback));
With a valid session I then call a request using this code block:
new Request(
session,
graphPath,
bundle,
HttpMethod.GET,
new Request.Callback() {
#Override
public void onCompleted(Response response) {
Log.v(TAG, "response = xx" +
response.toString());
String age_min = "";
String age_max = "";
GraphObject graphObject = response.getGraphObject();
Map<String, Object> stateMap = graphObject.asMap();
try {
JSONObject age_range = (JSONObject) stateMap.get("age_range");
age_min = age_range.getString("min");
age_max = age_range.getString("max");
} catch (Exception e) {
Log.v(TAG, "error in parsing age_range here = " + e.getMessage());
}
Log.v(TAG, "logging the age_range min here = " + age_min);
Log.v(TAG, "logging the age_range max here = " + age_max);
if (!"".equalsIgnoreCase(age_max)) {
if ("18".equalsIgnoreCase(age_max)) {
age_range = "0-18";
} else if ("21".equalsIgnoreCase(age_max)) {
age_range = "18-21";
}
} else if (!"".equalsIgnoreCase(age_min)) {
if ("18".equalsIgnoreCase(age_min)) {
age_range = "18-21";
} else if ("21".equalsIgnoreCase(age_min)) {
age_range = "21-100";
}
}
Log.v(TAG, "and here in FB2 the age_range is = " + age_range);
}
}
).executeAndWait();
Where:
session (string) --> valid and currently opened session
graphPath (string) --> this is the fb userID (can be "me" but I haven't tested that, please let me know if "me" works.
bundle --> is the K,V parameter that you will request, in the age_range case it is:
Bundle bundle = new Bundle();
bundle.putString("fields", "age_range");
Please note that the request code block (at least in my case) was done inside the doinBackground of inner AsyncTask) --> thus my use of the executeAndWait() method instead of the executeAsync().
Hope this will help someone with the same problem. Thanks!
You can retrieve only currently logged-in user's OWN age_range and can not query other's age therefore you get no response when provided user_id is not the same as own id
see https://stackoverflow.com/a/30731037/4990217
You'll have to explicitly tell the API that you need age_range, as part of the public profile (no special permissions required). The user's age range may be 13-17, 18-20 or 21+.
/* make the API call v.2.3 */
FB.api(
"/me?fields=age_range",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
read documentation https://developers.facebook.com/docs/graph-api/reference/age-range/