web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

JSON-RPC via Ajax request

(0) ShareShare
ReportReport
Posted on by

Hello,
I've been looking for a way to get the result of the JSON-RPC for a while, without having to interface with PHP. Preferably via AJAX via jQuery for your own web app.
It hapert already when simply calling the 'RpcInfo.GetServerSettings'. Although I get back a 200 status, but the body is 'undefined'.
With the PHP API, I get the right information, so I think something is wrong with the request.
LOGIN DATA and HOST were masked for security reasons!

const md5     = require('md5');
const request = require('request');
const btoa    = require('btoa');
var url  = 'https://MyHOST:443/json/',
    user = 'MyUSER',
    pass = 'MyPASS',
    uniqueID = md5('My-app' + Date.now());
require('ssl-root-cas').inject();
request.post({
    method: 'post',
    uri: url,
    headers: {
        'Authentication': 'Basic ' + btoa(uniqueID + '-' + user + ':' + pass),
        'Content-Type': 'application/json'
    },
    json: true,
    body: JSON.stringify({
        version: '1.1',
        method: 'RpcInfo.GetServerSettings'
    }),
    rejectUnauthorized: false
}).on('response', function(data) {
    console.log(data.statusCode, data.body);
})

Have I forgotten some permissions, or is there a missing parameter in the header for the request?
Authentication seems to work, otherwise I would certainly get no 200er. Or is that technically not possible to get the response via Ajax correctly?
Does anyone have an idea here, or am I wrong here?

I would be glad about a short feedback.

    *This post is locked for comments

    I have the same question (0)

    Under review

    Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

    Helpful resources

    Quick Links

    Responsible AI policies

    As AI tools become more common, we’re introducing a Responsible AI Use…

    Neeraj Kumar – Community Spotlight

    We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

    Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

    #1
    SA-08121319-0 Profile Picture

    SA-08121319-0 4

    #1
    Calum MacFarlane Profile Picture

    Calum MacFarlane 4

    #3
    Alex Fun Wei Jie Profile Picture

    Alex Fun Wei Jie 2

    Last 30 days Overall leaderboard

    Featured topics

    Product updates

    Dynamics 365 release plans