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
SFDC LearningSFDC Learning 

Issue when integration ( Salesforce to Salesforce) using Rest API

My apex class : 

public class fatchAccountRecords{
    public static String fetchAccounts(){
        string strSessionid = loginsalesforce.login();
        HttpRequest req = new HttpRequest();        
        //String strEndpointURL = '';
        String strEndpointURL = '';
         Account acc=[select id,name,phone,website from account where id='0019000001nz3Zq'];
        req.setBody('<?xml version="1.0" encoding="UTF-8"?><request><name>'+ naame +'</name></request>');
        req.setHeader('Authorization','Bearer '+strSessionid );
        req.setHeader('Content-Type', 'application/json; charset=UTF-8');        

        HttpResponse res =  new Http().send(req);
        system.debug('response'+ res);
        system.debug('response'+ res.getBody());
        return res.getBody();

On destination org APEX class: 

global with sharing class MyRestResource {
    global static String doPost(String name) {
        Account account = new Account();
        account.Name = name;
       // = phone;
       // = website;
        insert account;
        return account.Id;

It is giving the15:46:12:444 USER_DEBUG [25]|DEBUG|response[{"message":"Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [line:1, column:2]","errorCode":"JSON_PARSER_ERROR"}] 

Thanks in advance
Chandra Sekhar CH N VChandra Sekhar CH N V
Do you have any input for JSON data?
SFDC LearningSFDC Learning
I am just forwarding account data in destination org in body
SFDC LearningSFDC Learning
I have actually just started to work on rest api. So please can you suggest me where i am wrong in it? 

Thank you chndra sekhar
Chandra Sekhar CH N VChandra Sekhar CH N V
Its just an issue with the format you are sending your JSON response. (