function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bujji vBujji v 

HTTP Post request comming to URL

Hi,

 

I have a doubt I am getting HTTP post request from campaign monitor to my salesfroce URL in the form of JSON.

I got this message in my debug log

 

Accept-Encoding=gzip, deflate, Cache-Control=no-cache, no-store, max-age=259200, Connection=keep-alive, Content-Length=201, Content-Type=application/json

 

 

 

when i used ApexPages.currentPage().getHeaders();

 

 

Now I need to retrive the JSON data, anyone please help me...

 

 

Thanks in advance.

Ashish_SFDCAshish_SFDC

Hi Srikanth, 

 

See the links below, should answer your questions, 

 

Problems Parsing JSON Responses with Apex

http://blog.jeffdouglas.com/2009/12/28/problems-parsing-json-responses-with-apex/

 

System.JSONParser
01	//resp is a JSON string
02	JSONParser parser = JSON.createParser(resp);
03	while (parser.nextToken() != null) {
04	    if ((parser.getCurrentToken() == JSONToken.FIELD_NAME)){
05	        String fieldName = parser.getText();
06	        parser.nextToken();
07	        if(fieldName == 'access_token') {
08	            accesstoken = parser.getText();
09	        } else if(fieldName == 'expires_in'){
10	            expiresIn = parser.getIntegerValue();
11	        }
12	}
13	}

 http://wiki.developerforce.com/page/Getting_Started_with_Apex_JSON

Bujji vBujji v

Actually I am not getting the data in the URL, I am getting the data in some encoded format as I mentioned like gzip, deflate format,, Now I want to read that data from that format...How can I do this?

 

Thanks,,

Ashish_SFDCAshish_SFDC

Hi Srikanth, 

 

You might have to use: 

 

apexpages.currentpage().getURL() and apexpages.currentpages().getHeaders().get('HOST')

Also see the blog, 

 

http://www.jesselorenz.com/2008/09/visualforce-determine-salesforcecom.html

 

 

Regards,

Ashish

Bujji vBujji v

Hi,

I dont want Host URL.. actually Campaign Monitor is sending data to my salesforce  site url in the Form of HTTP Post request in the format of JSON.

 

I want to retrive that data, When i was using ApexPages.currentPage().getHeaders()


I am getting Accept-Encoding=gzip, deflate, Cache-Control=no-cache, no-store, max-age=259200, Connection=keep-alive, Content-Length=197, Content-Type=application/json, Host=.... in my debug log.

 

I want to retrive that JSON data ..

Ashish_SFDCAshish_SFDC

Hi Srikanth, 

 

Use the tool http://fiddler2.com/ and call the method, you can click on JSON and get the required response. 

 

You have to call the method, and in debugger, click on inspectors Tab and click JSON. 

 

Regards,

Ashish

Ashish_SFDCAshish_SFDC

Hi Srikanth, 

 

See the Fiddler sample Image below, 

 

http://tinypic.com/r/8yrera/5

 

Regards,

Ashish

Ashish_SFDCAshish_SFDC

Hi Srikanth, 

 

See the Screenshot of JSON captured in Fiddler

 

http://tinypic.com/r/2ih9qtd/5

 

Regards,

Ashish