Azure: getting invoice data with the BillingManagementClient class - c#

The last line of the following code results in an "Operation returned an invalid status code 'BadRequest'" exception and I don't understand why:
Given the following code :
var tenantDomain = ConfigurationManager.AppSettings["TenantDomain"];
var clientId = ConfigurationManager.AppSettings["ClientID"];
var secret = ConfigurationManager.AppSettings["ClientSecret"];
var subscriptionId = ConfigurationManager.AppSettings["SubscriptionID"];
var serviceCreds = await ApplicationTokenProvider.LoginSilentAsync(tenantDomain, clientId, secret);
var bmc = new BillingManagementClient(serviceCreds);
bmc.SubscriptionId = subscriptionId;
List<Invoice> allInvoices = bmc.Invoices.List().ToList();
Suggestions anyone ? Should I specify a date period explicitly ? How?

Suggestions anyone ? Should I specify a date period explicitly ? How?
If we want to access Billing we need to assign the Billing Reader role to someone that needs access to the subscription billing. We could get the detail steps for the azure official tutorials. I also test the code you mentioned, there is no issue with code, if it is supported. The following is the snippet from the official tutorials.
The Billing Reader feature is in preview, and does not yet support enterprise (EA) subscriptions or non-global clouds.
Please have a try to login Azure Portal to check whether have access to Access to invoice. If you see the Access to invoice is disabled, it seems that the subscription type is not supported.
If you still have further questions, could contact support to get your issue resolved quickly.

Related

androidpublisher api google authorname empty

I have been testing the google api to get the comments of my android application in google play and it always returns me the empty authorname, do I need some other permission? I put the json of what returns me.
Thank you!
I suspect this is an issue with fields
var request = service.Reviews.List ("my.app");
request.Fields = "*";
var results = request.ExecuteAsync() ;
I don't have access to that api so the code is an educated guess give it a try let me know if it doesn't work. Try testing it here as well Google APIs explorer.
Update 1:
I have one last guess try running a Reviews.Get request after your review.list maybe the name isn't return in the list it should be though.
var request = service.Reviews.Get("my.app",reviewIdFromListRequest);
request.Fields = "*";
var results = request.ExecuteAsync() ;
If this doesn't work i say we log it as a bug.
Update 2:
apparently its a documented bug
Found in this documentation page reviews

Azure invalid AccessToken

i am trying to use Microsoft.Azure.Management.Resources library to manage some Azure resources. I have registered app in Azure AD and i gave it all permissons. I took its ApplicationId and Secret + TennantId and SubscriptionId and tried to obtaion AccessToken like this:
var clientCredential = new ClientCredential(_model.DeploymentDetails.CliendId, _model.DeploymentDetails.ClientSecret);
var context = new AuthenticationContext("https://login.windows.net/"+model.DeploymentDetails.TennantId);
_accessToken = context.AcquireTokenAsync("https://management.azure.com/", clientCredential).Result.AccessToken;
_resourceManagementClient = new ResourceManagementClient(new TokenCloudCredentials(_model.DeploymentDetails.SubscriptionId,_accessToken));
I get some AccessToken. BUT when i try to use it like this:
var x = _resourceManagementClient.ResourceGroups.List(...);
I get this error:
Additional information: InvalidAuthenticationToken: The received access token is not valid: at least one of the claims 'puid' or 'altsecid' or 'oid' should be present. If you are accessing as application please make sure service principal is properly created in the tenant.
Any ideas?
Thank you very much.
As far as I know, Microsoft.Azure.Management.Resources.dll that implements the ARM API. We need to assign application to role, after that then we can use token in common. More information about how to assign application to role please refer to the article .This blog also has more detail steps to get AceessToken.

Adding invoice to quickbooks online using .NET IPP QBOV3 SDK

using .NET IPP QBOV3 SDK
I have been working (struggling) on a small integration project all week.
The purpose of the project is to be able to have some accounts integration between a windows desktop client application, to quickbooks online.
I want to be able to -
Create new customers/suppliers (can do this)
Add sales invoices (cannot do this)
Return credit balances (not even tried this yet)
After reading a few forums, and articles to come to the understanding the QBOV3 .NET SDK was the one to use, for two reasons.
I'm going to use C# .net, as a winforms application to code the
functionality I need (this allows me to have the functionality integrated in the
current system, a this is also written in c# .net winforms)
It seems intuit say this is the way to go, as all over APIs are
going to be depreciated.
So, my first hurdle was the OAuth - which eventually I managed to figure out. I can now authorise and connect to my QBO sandbox account - great!
I can also create customers from the winforms application, and they appear in QBO - also great!
The next step, which has stumped me for the last 2 or so, is to be able to create an invoice for a customer - I just cant seem to figure out what to do. I am constantly getting a 'Bad request' error.
I have found next to no examples online on how to do this from a c# winforms application. It cant be that hard - so I'm really kicking myself at the moment.
Any help, or sample to set me in the right direction would be appreciated.
I cant believe no simple examples exist of this already - I guess not many are doing this via a desktop winforms application, or I am just looking in the wrong places - or have missed something obvious!
Reading through the API documentation is confusing, and doesn't really offer any sample code. I would of thought adding a sales invoice would be a pretty big thing to cover.
Here is the code I am currently using to gain some simple functionality - creating the customer works fine (if the customer doesn't exist in qbo - this is something I need to check before adding - so any steer on that would be great also)
Here is the code I cobbled together so far..
private void button2_Click(object sender, EventArgs e)
{
string consumerKey = "consumerKey";
string consumerSecret = "consumerSecret";
string accessToken = "accessToken";
string accessTokenSecret = "accessTokenSecret";
string appToken = "appToken";
string companyID = "companyID"; //realmID
OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerSecret);
ServiceContext context = new ServiceContext(appToken, companyID, IntuitServicesType.QBO, oauthValidator);
//uses production as default, which is https://quickbooks.api.intuit.com
context.IppConfiguration.BaseUrl.Qbo = "https://sandbox-quickbooks.api.intuit.com/";
//If not set, the default base URL, https://quickbooks.api.intuit.com, is used
DataService service = new DataService(context);
//add customer
Customer customer = new Customer();
customer.CompanyName = "Jims Junk";
customer.GivenName = "Jim";
customer.FamilyName = "Little";
customer.PrimaryEmailAddr = new EmailAddress() { Address = "test#test.com", Default = true };
customer.DisplayName = "Jims Junk Ltd"
Customer resultCustomer = service.Add(customer) as Customer;
//invoice
//-An invoice must have at least one Line that describes an item.
//- An invoice must have CustomerRef populated.
//- The DocNumber attribute is populated automatically by the data service if not supplied.
//- If ShipAddr, BillAddr, or both are not provided, the appropriate customer address from Customer is used to fill those values.
//-DocNumber, if supplied, must be unique.
Invoice invoice = new Invoice();
invoice.DocNumber = "uniqueNumber";
invoice.TxnDate = DateTime.Today.Date;
invoice.TxnDateSpecified = true;
invoice.CustomerRef = new ReferenceType()
{
name = customer.DisplayName,
Value = resultCustomer.Id
};
Line invLine = new Line();
invLine.Amount = 10000;
invLine.DetailType = LineDetailTypeEnum.SalesItemLineDetail;
invLine.Description = "Test Product";
invoice.Line = new Line[] { invLine };
Invoice resultInvoice = service.Add(invoice) as Invoice;
}
Sods Law, after a few days of not finding anything - Just now I find a code sample that has helped.
I have now managed to get an invoice posted into QBO.
Here is the linked that helped - http://developer.qbapi.com/Create-Invoice-Error---Bad-Request.aspx
ill just leave it here, so that others may benefit if struggling.
Thanks for reading.

Connect to Kiln mercurial repository using C#

I use Kiln.Net library to connect to mercurial repository. I need to get base information (commits, lines of code changed..). Then it should group that info further to show progress for each author. But still have no success.
Code to connect:
var account = "exampleRepo"; // examplerepo.kilnhg.com
var user = "exampleUsername"; // username
var password = "examplePassword"; // password
using (Kiln myAccount = Kiln.AuthenticateOnDemand(account, user, password)) // Here 404 error
{
// Returns changeset history for the repository
Changeset[] changesets;
changesets = myAccount.GetHistory(repo.ID, 100);
// Returns the list of all available projects
Project[] projects;
projects = myAccount.GetProjects();
projects = myAccount.Call<Project[]>(KilnApiCall.Projects, null);
}
While debuggin I got that auth URL seems good. It is like:
https://exampleRepo.kilnhg.com/Kiln/Api/1.0/Auth/Login?sUser=exampleUsername&sPassword=examplePassword
But after execute request I always getting 404 error Not Found. Thanks in advance for your help
The problem was fixed. Kiln.Net library was generating bad URL. Good one is just without "/Kiln":
https://exampleRepo.kilnhg.com/Api/1.0/Auth/Login?sUser=exampleUsername&sPassword=examplePassword

Get facebook feed for particular users C#

I am developing a server application that should be able to react to the amount of likes for some of the posts in the user's feed.
I need to get post from users wall.
I'm using Facebook library version 6.4.2
I use the following code to get the posts:
var apiKey = ConfigurationManager.AppSettings["apiKey"];
var secret = ConfigurationManager.AppSettings["secret"];
var client = PostHandler.CreateFacebookClient(apiKey, secret);
var get = client.Get(string.Format("/{0}/feed", pageId));
and/or (both return the same info)
var token =ConfigurationManager.AppSettings["token"];
var get = client.Get(string.Format("/{0}/feed?access_token={1}", pageId, token));
The problem is that using the same set of permissions the json returned from the request above is different from the json returned from json returned from Graph API Explorer methog GET 100000481752436/feed
In my opinion the json returned from my request is missing some posts and the one from the Geaph API all contains the posts from my feed.
Could you please advice, what could I have missed ?
If you are missing some posts in the feed it is most likely that you'll have to check the permissions set again.
Based on the type of posts you are missing you maybe have to add the user_status, user_activities, user_friends, user_checkins or user_games_activity permissions. Please make sure that you're using the correct set of the permissions for your particular task.
If you'll specify the type of the posts you are missing you may get much more helpful answers.

Categories

Resources