Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

JSON odata error - Bad Request. Bad syntax or something else?

$
0
0

I can't seem to egt the data I need with our JSON script in our CRM environment.

The script looks like this:

function SetMedlemsgrupp() {
    try {
        var utbildning = Xrm.Page.getAttribute('stc_utbildning_id').getValue();
        if (utbildning != null) {
            $.ajax({
                type: "GET",
                contentType: "application/json; charset=utf-8",
                datatype: "json",
                url: '/JUTVECKLING/XRMServices/2011/Organization.svc/stc_utbildningSet(guid\'' + utbildning[0].id + '\')?$select=stc_medlemsgrupp_id',
                beforeSend: function (XMLHttpRequest) {
                    XMLHttpRequest.setRequestHeader("Accept", "application/json");
                },
                success: function (data, textStatus, XmlHttpRequest) {
                    var medlemsgrupp = data.d.stc_medlemsgrupp_id;
                    if (medlemsgrupp != null) {
                        var medlemsgruppLookup = Xrm.Page.getAttribute('stc_medlemsgrupp_id');
                        medlemsgruppLookup.setValue([{ id: medlemsgrupp.Id, name: medlemsgrupp.Name, entityType: medlemsgrupp.LogicalName }]);
                    }
                },
                error: function (XmlHttpRequest, textStatus, errorThrown) {
                    alert('Odata select failed, status: [' + textStatus + '], error: [' + errorThrown + ']');
                }
            });
        }
    }
    catch (e) {
        alert(e.toString());
    }
}

What I get in response is "Bad Request". I can connect to the same URL with LINQpad so I know its reachable and that the params exists.

Is the syntax wrong or does anyone have any idea what might be the problem?

Regards

Linus



Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>