Thursday, April 23, 2015

Office 365 Dev Camp is near your city ?

Hi All,

If you are looking to get up to speed in office 365 application development. I have good news for you!

Microsoft is planning to have Office 365 in every major city in US, check out the schedule and save your seat today.

The dev camp is a one day deep dive in building office 365 applications including Office Word, Outlook, SharePoint Apps, Office 365 API and more.

Check out all office Dev Camps events in the below link:

http://aka.ms/msdevcamps


For local friends, The Washington DC office 364 dev camp event will be in 6/1 for Office 365 Dev Camp!


DC office 365 Dev Camp direct link to sign up!



The link above has other dev camps for cloud data and IoT dev camps.


Enjoy!





Tuesday, April 14, 2015

How to fix 'thumbprint' attribute is invalid error in Azure Cloud Service

Hi,

While i was configuring a web role in a cloud service project to use SSL certificate, I was adding my certificate to the Service Configuration file (cscfg) as follows:

  <Certificate name ="MyCertTest" thumbprint="cd947ee0b988e3b144d9fc39af47128dec68b731" thumbprintAlgorithm="sha1"/>
 

After i copied the thumbprint value from my certificate and paste it in the configuration file (cscfg) i found that there is an underlying error under thumbprint attribute and when i build i get the following error:

the xml specification is not valid: the 'thumbprint' attribute is invalid the pattern constraint failed


Here is the steps on how to fix it:

1) Remove any spaces from the thumbprint value.
2) There was a hidden character at the beginning and end of this string and once i removed it the underlying error in the cscfg file went away.
3) Save your changes and build!
4) Deploy your cloud service to Azure.


Hope this helps.


Sunday, April 12, 2015

How to return JSON objects from Web API 2

Hi All,

I was trying to return an object from web api 2.0 and i was getting the following error:

The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.

The inner exception message was stating the following:

Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'Newtonsoft.Json.Linq.JToken' to remove references to itself.


Sample method:

[HttpGet]
[ResponseType(typeof(ChargifyTransaction))]      
public async Task<MyObject> GetTransactionDetails(string transactionId)

{

   MyObject obj = new MyObject();
   obj.Id=123222;
   obj.Name = "Mostafa dev";
   
   return obj;
}

The solution:

Add the following 2 lines in Global.asax file under App_Start method, This will force the web api to return Json formats and to ignore references to itself for Newtonsoft.Json dll.



 protected void Application_Start()
        {
            // Force to use Json formatter and ignore reference looping.
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);


           }


Hope this helps.