Skip to main content

Posts

Showing posts from December, 2012

JSON to Apex Convesion simpler now with http://json2apex.herokuapp.com

With the REST API being lot used when integrating apps developed on force.com paltform with the mobile applications or integrating force.com with external applications communicating using JSON it becomes vital to know few of open source tool we have to make our task simpler.

When we are in technology consulting world the time becomes crucial in any project we face .
There are couple of tools that i normally use whenever an integration is using REST API and the format of data communication is in the form of JSON .
In this blog i will describe two commonly used applications that makes life simpler when dealing with the JSON data.
1)http://jsonlint.com/
This application is very useful to format and Validate the JSON .All you need to do is input the JSON in the text box provided and click on Validate button to Validate the JSON .
JSON Lint is a web based validator and reformatter for JSON, a lightweight data-interchange format.
2)http://json2apex.herokuapp.com/
This was recently developed b…

Handling PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException exception in SFDC Callout

Recently i encountered an exception during making a Callout to the external service .Being an apex developer and unfamiliar with SSL concept much with no luck after googling i tried posting the question in stackexchange Stackexchange link.I am thankful to the Martin Peters for helping me on this .

Through this blog post i would like to document few points i learned on cause of this exception and also i will indicate the solution and resources we have that can help us to get rid of this exception
1)First way to identify this exception is if we try to open the URL we are using to  make a callout to external system in any browser we will encounter the security exception.The below image shows how our browser will behave once encountering such SSL exception.

2)This happens when the external system we make callout from the salesforce does not have valid SSL certificate 
For the JAVA client we have solution on the discussion board .http://boards.developerforce.com/t5/General-Development/PKI…

Oauth 2.0 Salesforce Using REST Console of Chrome Browser

Earlier in one of my blog post i had demonstrated on how to use Mozilla Poster tool to verify the REST API calls of the salesforce.

Using Chrome REST console has several advantages than poster mozilla .The response can be seen in both JSON and XML and also the concept of oauth 2.0 also can be practically understood .

There are very good articles on 2.0 on the developer.force.com and here is the link Digging deeper into Oauth 2.0

The workbench.developerforce.com has an excellent REST utility which helps in quick verification of Restful Apex services or even standard REST API exposed by the salesforce .One major disadvantage of this is since the oauth happens automatically the conceptual knowledge on how oauth 2.0 works is hidden .

In this blog post we will use the REST Console of the chrome and first get the oauth token from the salesforce instance and then will invoke the REST service from the salesforce .

Step 1-Getting oauth token from salesforce instance 

First step is to set up th…

Writing Test Classes For Apex Rest Service

I came across a question in a developer community on how to write Unit Test Classes for the Rest API service for POST HTTP calls

Unit Test Classes for REST API following link is very useful and inspired by this jeff had an article on his blog on how to write the test method for same .

Here is the Jeff Blog Link Test Class for REST API(Good reference for GET Rest Services)


In one of my previous blog post i demonstrated how to use native parsing technique for Rest api for User Defined Type
I wrote the Test class for the same and this post is helpful for all those searching for how to write test classes for apex rest service annotated with POST Call
Here is the Rest Service Class for which i attempted the test class
@RestResource(urlMapping='/DemoUrl/*') global with sharing class MyRestResourcedemo { global class RequestWrapper{ public Account acct; public Contact[] cons; } global class ResponseWrapper { public String StatusCode; …