Azure logging API sample - c#

I have tried the C# sample at https://learn.microsoft.com/en-us/azure/azure-monitor/platform/data-collector-api butI always get an error response back. Has anyone been able to get this sample to work? I have double and triply checked the workstation id and the secret key but still cannot call the API sucessfully.

Yes, as Doris Lv mentioned, displaying the error would certainly help to understand the issue better.
In additional to it what I could observe in general is, the C# example provided for the Azure Monitor Data Collector API uses ASCII encoding while other parts of the page reference UTF8 so try to tweak your code with UTF8 and see if it resolves your error.

Related

Accessing Acumatica through VB.Net ... getting started

Is anyone using VB.Net to access the Acumatica contract based REST API? I really need some help getting started. I am experienced in VB.Net, but new to Acumatica and I am a little overwhelmed by all of the documentation. I just want to start with something simple ... for example, log into Acumatica, get a list of stock parts & log out. Does anyone have any VB.Net code they would be willing to share? Or maybe a tutorial you could point me to? I spent a few hours looking through a lot of documentation but could not seem to find what I was looking for to get me started. I would appreciate any help you can provide. Thanks in advance...
I wrote a PHP binding for the Acumatica REST APIs. Some of the criticisms above are somewhat valid...it's a little unique as APIs go, and not very well documented. That's why to get started... you will want to get Postman: https://www.postman.com/
In Postman, setup a POST request to http://youracumsticaurl/entity/auth/login
Use JSON body with your user/pass/company details:
{
"name" : "admin",
"password" : "yourpass",
"company" : "Company name full text",
"locale" : "en-US"
}
for company....use the full text of the company in the tenant...not the id.
Next with Postman do a simple get request for an item:
http://localhost/Acumatica2021R2/entity/Default/20.200.001/StockItem/someitemid
...where "someitemid" is a valid stock item id
Once you get that far, you can start using Postman to write your VB.NET API calls. Here is some info on calling a REST web service with VB.NET: https://dotnetco.de/setup-post-rest-webservice-asp-net-vb-net/
It takes some messing around but the REST API works pretty well once you get your calls setup correctly. I login and logout on every call, which is probably not best practice but avoids some of the session management headaches with cookies and Acumatica. YMMV with that depending on use case and call volume.
I use the rest api client available on the Acumatica github site. (link below)
I'm using C# in my project, but there's no reason you couldn't use this library with vb.net.
I had to update the library to add custom fields and custom endpoints which would require you update the code in C#, but if you just want the base endpoints it should work fine.
https://github.com/Acumatica/AcumaticaRESTAPIClientForCSharp

ABP.io angular cannot read property replace of undefined

I'm using Abp.io for .net backend and angular for frontend, I've the backend up and running and works pretty ok on swagger.
However when I generate proxies for the backend with the command "abp generate-proxy" it throws me an error saying "cannot read property replace of undefined" and that's bout it, I've no clue where to look for errors.
Note I've generated proxies before and I know how they look inside an angular project but after adding more endpoints I keep getting this error, I've also attached a screen shot just in case you want to have a look at it.
I would really appreciate some help, thanks guys.
I also received this error. I believe this occurs if there are no models/services to generate. After adding my first model and CrudService the error never re-appeared.
I figured it out. First there was a JSON serialize in startup file that was causing that error and the frontend project's API address was targeting to the live instead of the local one.

Not all data come from server

I am sending object from ASP.NET WebAPI:
It is really strange, but there is no this object at client Angular 4:
I cannot understand where is the MP_ShipmentLines object? What can be a reason? How can I solve it?
I've assigned 'CarCount' at client side. There is no additional processing and this is the same object.
I will tell you some debuging tricks, hope to solve your problem:
1- check address that you requesting to in browser url, it must show you a json you can check your json at jsononlineditor.org, it will show you is your api works fine or not
2- print your resived data where you subscribe your request check this cause some problem like this is related to mapping json to your object
Leave part of your code here to others can give you better answers, till now we only know you have problem and there is no idea why. and it wouldn't be angular or .NET problem.

WCF Content-Length mismatch when using IIS Compression

I have an issue where if I enable dynamic content compression in IIS 7.5, I get a different content length. I know this could happen since the data is being compressed but the problem is it is actually bigger.
Before
After
I know there are related posts like this one but the solutions are often modules modifying the content-length. In this example, I ruled that out by using a simple demo WCF app but I still get an incorrect content length. IF you think I missed the correct question / answer, just let me know.
WCF service returns incorrect Content-Length when using gzip encoding
Here is the solution of the demo wcf I am using. https://github.com/janmchan/WCFDemo.git
As it turns out, there was nothing wrong with the response. Using fiddler, I could see the saw response as the compressed version and it seems that the length corresponds to the length of those characters. So our conclusion is that the end system receiving this does not know how to handle the compressed response. I'll keep this answer open for debate until we have confirmed that this is the case.

Is Twitter implemeting OAuth off spec? (C#)

I've been battling with OAuth and Twitter for 2 weeks now trying to implement it. After many rewrites of my code I've finally got a library which performs the request as it should be based on the 1.0 spec. I've verified it by using this verifier on Google Code, and this verifier from Hueniverse.
My version, the Google version and the Hueniverse version all produce the exact same signature, so I've concluded that I am no longer the cause (but I could be putting a foot in my mouth by stating this...).
I test my implementation by first creating a test request using Twitter's API Console, in this case a status update. I copy the params that change, the oauth_nonce and oauth_timestamp, into all three signers stated above. All other params are always the same, tokens/secrets/etc.
Twitter's console produces one signature, but the other three above all produce a different signature (from Twitter's, identical to each other).
So, my question is, why am I getting this:
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<request>/1/statuses/update.xml</request>
<error>Could not authenticate with OAuth.</error>
</hash>
...when I should be implementing the spec to the "T"?
Is there something specific that Twitter needs/wants as part of the request? I've counted the nonce generated by Twitter as 42 chars long, is that correct? Should it be 42 chars long?
I would appreciate help from anyone with more insight into the API than I obviously have...
Thanks in advance!
UPDATE: Someone asked about how I send the authentication params, but has since deleted their post, idk why. Anyway, the authorization params are sent via the Authorization header.
UPDATE/SOLUTION: Is moved down to the bottom where it belongs as an answer.
The only problem I had when implementing the OAuth specification with Twitter as the main target was, that Twitter has restricted the nonce to only accept ASCII characters (while the specification actually allows any bytes). Therefor I changed my implementation to generate a random int (with 60 bits, so longer than 42 chars) instead.
Other than that, Twitter's implementation seems to be completely correct; at least I didn't have any issues.
I suggest you to use some of the many OAuth sandboxes around (for example this or this) to really check if everything goes right and for example if you include everything necessary into the signature etc..
A little late, but per #poke's suggestion, I'm adding my answer down here:
So, I figured it out, and it's actually quite stupid. A while back, probably rewrite 3, I was getting back bad non-XML response from Twitter. I then saw that in the Twitter API Console they escape the header params: param=\"value\". I added the backslash to mine and instantly I was getting back an XML response. So it stuck.
Anyway, just to rule everything out from rewrite 7 (or 8), I decided to remove the backslash from the header params string and it resolved everything.
So, the lesson learned from all of this is that not everything that the Twitter API Console displays should be mimicked. I actually would further suggest that Twitter updates the console to display what a header string should look like when sent and not what their system generates internally, which parses the backslash chars.

Categories