REST

312

Solutions

608

Contributors

Representational state transfer (REST) is an architectural style that gives a coordinated set of constraints to the design of components in a distributed hypermedia system used to design networked applications. RESTful systems typically communicate over Hypertext Transfer Protocol (HTTP) with the same HTTP verbs (GET, POST, PUT, DELETE, etc.) that web browsers use to retrieve web pages and to send data to remote servers. REST interfaces with external systems using resources identified by Uniform Resource Identifier (URI) that can be operated upon using standard verbs.

Share tech news, updates, or what's on your mind.

Sign up to Post

Experts,
 We have added javascript scripts to aspx page for check current user sid is  in Active Directory group or not. we calling web service to to check it. That code is working nice on google chrome and Edge but not working in IE. Looks like JSON in unidentified error i believe.

 When open with development tool and debug then sometime it's working. Can you please help me to identify the root cause? Also how can i add some code which can throw the error popup?

<script type="text/javascript" src="_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="_layouts/15/sp.js"></script>
<script src="https://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript" ></script>

<script type="text/javascript">




var userid= _spPageContextInfo.userId;
if(userid != undefined)
{
  var sys_sid = _spPageContextInfo.systemUserKey;
    var input_sid = sys_sid.split('|');
    var Outputsid = input_sid[1] || '';
   // alert(Outputsid);
    var setData={
    migratedSecurityGroup: "Sharepoint_Migrated",
    samSID:Outputsid
};

     $.ajax({
        type: "POST",
        url: _spPageContextInfo.webAbsoluteUrl+"/_layouts/15/SG_Test_AppPage/SG_Test_AppPage.aspx/IsMemberOf",
       data: JSON.stringify(setData),
        async: false,
        contentType: 'application/json; charset=utf-8',
success: function(data) {
            //debugger;
            if(data.d.length>0){
            console.log(data.d)
         //   alert(data.d);
             if(data.d == 

Open in new window

1
Announcing the Winners!
LVL 13
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

Expert
 I am having some problem with accessing web method by rest api. I am using below code and attaching the error code. Please help me to find out root cause.

function onSuccess(data, request){

    var group = "Group223";
    var user = "s-1-5-21-1106717361-1361586587-285947020-863586";
    var setData={
       migratedSecurityGroup: "Group223",
       samSID:"s-1-5-21-1106717361-1361586587-285947020-863586";
      };
  
    $.ajax({
        type: "POST",
        url: _spPageContextInfo.webAbsoluteUrl+"/_layouts/15/SG_Test_AppPage/SG_Test_AppPage.aspx/IsMemberOf",
       data:setData,
        async: false,
        contentType: 'application/json; charset=utf-8',
        success: function(data) {

            //debugger;
            if(data.d.length>0){
            console.log(data.d)
         //   alert(data.d);
             if(data.d == "True")
              {
                 document.getElementById("DIV1").style.display = "none";
                 document.getElementById("DIV2").style.display = "block";
 
               }
              else
              {
                  document.getElementById("DIV2").style.display = "none";
                  document.getElementById("DIV1").style.display = "block";
 
              }
           }
        },
        error: function (error) {debugger;
            console.log(JSON.stringify(error));
        }
    });

}

Open in new window


Error.PNG
0
Experts,
 We have some java script and reading data from sharepoint list. Some list item has more space and we need to trim it before we compare. The  original value is "California&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " and we need to replace to "California".

Can you please help me write some code?

original code
  var spClientContext = SP.ClientContext.get_current();
        var parentListName = 'DM Nomination List'; 
		var spList = spClientContext.get_web().get_lists().getByTitle(parentListName);
		var objResult;
		    
		    arrLstDMNomination = [];
		    
			var viewXml = "<View><Query><Where><Eq><FieldRef Name='Nominated' /><Value Type='Text'>1</Value></Eq></Where>";
				viewXml += "<GroupBy Collapse=\"TRUE\" ><FieldRef Name=\"Territory\"/></GroupBy></Query><ViewFields><FieldRef Name=\"LinkTitle\"/>";
				viewXml += "<FieldRef Name=\"Title\"/><FieldRef Name=\"Territory\"/></ViewFields><Aggregations Value=\"On\">";
				viewXml += "<FieldRef Name=\"Nominated\" Type=\"COUNT\"/></Aggregations></View>";
			 var groupBy = spList.renderListData(viewXml);
			 spClientContext.executeQueryAsync(function(){
			 objResults = JSON.parse(groupBy.m_value);
 			 
			  $.each(objResults.Row, function(idx, obj){
                var vTerritoryName = obj["Territory"];
			 	var vNominatedCnt = obj["Territory.COUNT.group"];
			 	arrLstDMNomination[idx] = { 'TerritoryName' : vTerritoryName, 'NominatedCount' : vNominatedCnt  };
              });	 
            

Open in new window

0
Experts,
 Our requirement to check user in AD group or not and based on result we have to display some texts. We are  calling rest api to check user is part of that group or not by passing some parameters. We are able to read current user and pass domain, user and group to rest api.

Now based on result we have to write some html. I need your help to review my existing code give suggestion to implement this functionality.
<script type="text/javascript" src="_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="_layouts/15/sp.js"></script>
<script src="https://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript" ></script>
<script type="text/javascript">

var userid= _spPageContextInfo.userId;
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
var requestHeaders = { "accept" : "application/json;odata=verbose" };
$.ajax({
    url : requestUri,
    contentType : "application/json;odata=verbose",
    headers : requestHeaders,
    success : onSuccess,
    error : onError
});

function onSuccess(data, request){

    var group = "AD_Group";
    var loginName = data.d.LoginName;
    var input = loginName;
    var x = input.match(/[^|]*\|([^\\]*)\\(.*)/)
    var user = x[2];
    var domain = x[1];

    var setData = { 'migratedSecurityGroup':group, 'User':user, 'domain': domain };
    $.ajax({
        type: "POST",
        url: 

Open in new window

0
Hello Experts,
 We have created the web service to check the user is belongs to Active Directory or not for our Access Denied Page. Now we have to use Rest Api to use the method. The web service has three parameters 1. Security Group 2. Username 3. Domain.

I will need to pass current user name and domain to this web service. This method return Boolean.  Based on value i have to display different html. I may have to use SPcontext to read current username and domain.

Function call()
{
setData="{'SecurityGroup':'','UserName':'','domainName':''}";
    $.ajax({
        type: "POST",
        url: _spPageContextInfo.webAbsoluteUrl+"/_layouts/15/FindUserSecGroupMembership/CheckUserADMembership.aspx/IsMemberOf",
       data:setData,
        async: false,
        contentType: 'application/json; charset=utf-8',
        success: function(data) {
                                                //debugger;
               //if(data.d.length>0){
                console.log(data)
           //}
                },
        error: function (error) {debugger;
            console.log(JSON.stringify(error));
        }
    });
}

Open in new window


Can you please help me to write code to pass username and domain and display html based on output?
0
I need to update an Excel Macro:

I have found a few macros that I have in my workbook that I would like to combine into one so I only have to run 1 macro, instead of 3.

I listed out the macros in the text file in the specific order I need to run them in. On the second macro, I need to update the following :

'Loop through each item in Array lists
  For x = LBound(myArray, 1) To UBound(myArray, 2)
    'Loop through each worksheet in ActiveWorkbook (skip sheet with table in it)
      For Each sht In ActiveWorkbook.Worksheets
        If sht.Name <> tbl.Parent.Name Then

I need it to NOT LOOP through the rest of the sheets in the workbook but just look at a specific sheet "Apple Worksheet"

And can there be some type of delay between each macro of 1 second?

Thanks for the help!!!!
MacrosExample.txt
0
I have 6 (16GB) memory modules and 3 dell server R710 that I would like to use. I would like to  spread these 6 sticks to 2 sticks each to each server. Is there a supported memory configuration that would allow me to do this. I also have 8GB sticks each to fill the rest of the slots.
0
I am learning .net core web api. I created a bare minimum web api project, with API template in visual studio.
The template comes with a controller and its actions methods, as below

//GET api/values
[HttpGet]
public ActionResult<IEnumerable<string>> Get(){
          return new string [ ] { "value1", "value2" } ;
}

//POST api/values
[HttpPost] 
public void Post( [ FromBody ]string value ) {

}

Open in new window


I started a rest client (chrome extension) to test and posted a get request to http://localhost/testweb/api/values.
Next, I wanted to test posting a XML in pay load, so in my rest client , I set the content type to (application/xml) and xml data in the body, but when i send the request.
I get "400 bad request" and "the input was not valid" in response.

Do i have to configure anything else to be able to get the xml data from pay load in a post request ?
0
I want to build a http REST service in node js. I have few Javascript files.

how can i call the different functions in these different javascript files, from say one server.js file that I write in node js for the REST service?
0
I have a server 2012 R2 running DFS.There is also another server 2012 r2 that has a share on there using DFS as well. I have 4 DC's, 2 onsite and 2 at another site. Everything was working correctly right up until I ran updates to all my servers and reboot them to apply updates. Now I am getting people randomly telling me that they cannot connect to shares when signing in. After a few reboots they could. I have checked DNS and it looks good. When a user is at a broken state, What always works is the home drive which is applied on the profile tab in AD. That is referenced to a dfs share. What sometimes works after a few reboots is the logon script that has the rest of the peoples drives that they haven't been getting consistently. Does anyone have an idea of whats going on. Thanks a head of time.
0
PMI ACP® Project Management
LVL 13
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

I have a network which consists of a SonicWall NSA 2600, two Cisco SG300-20, two 3COM  2952-SFP and one 3COM 2928-PWR.  We are putting an IP phone system in so I am creating a phone VLAN (VLAN 201).  See attached simple network diagram.  The two SG300s are attached via fiber and the rest are CAT6.

I created VLAN 201 on all devices and configured the SonicWall with an IP of 10.10.2.254  I configured the Ciscos with 10.10.2.57 and 10.10.2.56.  I can ping from all 3Coms to .254.  I can ping to .254 and .57 from .56.  I can ping .56 from .57 but I cannot ping .254 from .57.

Both Ciscos are configured for L3.  The ports that connect the two Ciscos are configured as trunk on both switches.

I have checked my settings multiple times and have had a co-worker look.  What am I missing?
Simple-Network-Diagram.xlsx
0
I'd like to query a REST API (for harvest, but I guess it is a pretty generic question) from Excel 2016.

I have all the parameters I need to pass, ie
curl -X POST https://api.harvestapp.com/v2/tasks \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Harvest-Account-Id: $ACCOUNT_ID" \
  -H "User-Agent: MyApp (yourname@example.com)" \
  -H "Content-Type: application/json" \
  -d "{\"name\":\"My New Task\"}"

Open in new window


But how do I use the Excel built-in wizard for this ?

Excel settings
0
Running Exchange 2016 CU8

I have an issue where one of the Queues on a server will show as Throttling.  This has happened to all my servers, but not at the same time.

I am able to temporarily resolve the issue by Suspending the Queues, Restarting the Exchange Transport Service, and Resuming the Queues.  However, the problem returns.  There does not appear to be a pattern I can recognize when this happens.

If I run the following command on the server with the Queue that shows as Throttling:

[xml]$bp=Get-ExchangeDiagnosticInfo -Process EdgeTransport -Component ResourceThrottling; $bp.Diagnostics.Components.ResourceThrottling.ResourceTracker.ResourceMeter

I see the following result.  The rest of the Resource Pools show as low.

Resource            : CheckpointDepth[D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\data\Queue\mail.que]
CurrentResourceUse  : High
PreviousResourceUse : High
PressureTransitions : [PressureTransitions: MediumToHigh=300 HighToMedium=280 LowToMedium=250 MediumToLow=230]
Pressure            : 382

The only relevant correlation I can find is the Max Checkpoint Depth Setting in the EdgeTransport.exe Config file.

<add key="DatabaseCheckPointDepthMax" value="384MB" />

I have plenty of disk space available if needed to modify these settings.  What can I change to prevent this issue from re-occurring?  Are there other parameters I need to look at?

Any help would be appreciated.  Thanks.
0
All of the sudden I have lost my regular view when I open a folder in Windows 10.  I tried all the different View options and non of them worked.  My normal view has always been to show all the columns across the entire with of the folder but now I have this space on the right preventing the rest of the columns to show up.  How can I fix it.
Thanks See pic.Pic 1
0
I added a few new columns into the staff tab and the AFT tab. I also added in the rest of the year for the house tabs. This seemed to mess up some of the VBA that has been written for my program.  Can this be fixed? Also, I was wondering if the Shift date tab could have a calendar drop down rather than writing in the date.

Thanks!
Dec-30th-Schedule.xlsm
0
I am attempting to resolve an issue WCF Rest Service and I am able to step through debug in one way:

I am able to step-through by calling on the URL specifying the method on the URL:

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/GetMember/{strTest}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        string GetMember(string strTest);

Open in new window


But what I really needed is more like an object in the RequestBody. So, I originally had:

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/GetMember",  RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        GetTestMemberRes GetMember(GetTestMemberReq TestMemberReq);

Open in new window


I am getting this:
Results of test
And it does not even hit the breakpoint.

When I do the first operation contract I had to change the signature of the method. But when I do that and use the GET as well as update the URITemplate it works and I hit the break point but when I change it to a POST and use the object GetTestMemberReq. I get the above?

If the first one is working my config changes should be good.

I am using C#, .NET 4.0, and VS 2017.

Any information as to what I might be doing incorrectly.

Very much appreciated.
0
Is it possible to use Visual Studio and step through debug of a REST service using the WCFTestTool? If so, how is that done?  I have a set of SOAP WCF services but I need to do a REST as well. I know one can do a WebInvoke after the OperationContract like:

[WebInvoke(Method = "POST", UriTemplate = "/GetTest",  RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]

The code is C# and Visual Studio 2017.

I do *not* have localadmin access.

Any information on that would be greatly appreciated.

Thanks!
0
Hi,

It has been a long while since I have had to do this and was hoping someone could help me out.

basically I am getting returned this xml packet:
<?xml version="1.0"?><BCAmessage service-request-id="10630513389" type="RESPONSE"><BCAservices><BCAservice><BCAservice-code>BCA001</BCAservice-code><BCAservice-code-version>V00</BCAservice-code-version><BCAservice-client-ref>1 </BCAservice-client-ref><BCAservice-data><response version="1-36-0">
<enquiry-report>
<primary-match type="no-match"/>
<general-message>NO EXISTING FILE FOUND FOR THE SUBJECT OF YOUR ENQUIRY</general-message>
<summary-data>
<summary currency-code="AUD" name="enquiry-amount" type="amount">0</summary>
<summary name="age-of-file" type="months"/>
<summary name="age-of-subject" type="years"/>
<summary name="time-at-address" type="months"/>
<summary name="time-at-employer" type="months"/>
<summary name="defaults" type="count">0</summary>
<summary currency-code="AUD" name="defaults-value" type="amount">0</summary>
<summary name="defaults-paid" type="count">0</summary>
<summary name="defaults-12" type="count">0</summary>
<summary name="defaults-12-paid" type="count">0</summary>
<summary name="defaults-12-unpaid" type="count">0</summary>
<summary name="defaults-24-paid" type="count">0</summary>
<summary name="defaults-24-unpaid" type="count">0</summary>
<summary name="defaults-36-paid" type="count">0</summary>
<summary name="defaults-36-unpaid" type="count">0</summary>
<summary 

Open in new window

0
Has anybody here managed to do a PUT request (any language) to the Wordpress Rest API for an ADVANCED custom field?.
I managed to perform a PUT request to Wordpress Fields but tried to do a simple PUT to an acf?
(get works fine).
I use postman to do my testing.
maybe I don't understand the syntax.
the error does not help me and gives me:
{
    "code": "cant_update_item",
    "message": "Cannot update item",
    "data": {
        "status": 500
    }
}

herre is a psuedo Pseudo api url
with the PUT request to show my syntax (assume I authenticated with basic authentication).

 https://somewebsite/wp-json/acf/v3/pages/735?dog_name=somthing


Thank You
0
C++ 11 Fundamentals
LVL 13
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

I am trying to update a custom filed using put requests in POSTMAN
I manage to update the page title slug or any filed which wordpress created.(fields)
For example I have :
if I do a get request :
https://breeding-portal.mystagingwebsite.com/wp-json/acf/v3/pages/735
you will see :
{
    "acf": {
        "dog_name": null
    }
}

What I want to do is update dog_name I have tried multiple solutions.
the PUT request echoes :
{
    "code": "cant_update_item",
    "message": "Cannot update item",
    "data": {
        "status": 500
    }
}
Anyone solved this ?
0
I have an MS Access / VBA application running on an RDP server.  I have been asked to interface with a phone system via REST API.  I haven't done this before, so could do with some help in relation go GET/POST commands.  However, I am also concerned about memory/processor overhead for each user.

So....I could really do with some advice.
0
I am working with JAMF - the Apple IT management application.  I am connecting to the Classic API (RESTful) using PowerShell (v4 and v5).  

I am capturing the name, id, serial_number, model, model_identifier, and model_display from the /mobiledevices endpoint.  I also need to capture the department field from the  /mobiledevices/id/{id}/subset/location subset - where {id} is the id captured in the first endpoint.

Re:  https://developer.jamf.com/#/mobiledevices

The results will be used to populate a different application either through SOAP or direct database updates. TBD.  We may also have to correlate the results with an Active Directory and so I thought PowerShell would be a good scripting base.  I come from a hodge-podge of scripting and admin backgrounds and only have a passing knowledge in PowerShell.

I still have problems with data structure objects and also converting my structured background to pipeline thinking.

Here is what I have:

# Authentication parameters
###########################
$RESTAPIServer = "test.jamfcloud.somewhere"

$RESTAPIUser = "WillyWonka"
$RESTAPIPassword = " OompaLoompas@r3it!"

$BaseURL = "https://" + $RESTAPIServer + "/JSSResource/mobiledevices"
$Header = @{"Authorization" = "Basic <ToBase64 string goes here>"}
$Type = "application/json;charset=UTF-8"
#--------------------------#

# Get all mobile devices
########################
Try 
{
$MobileDeviceResponse = Invoke-Restmethod -Uri $BaseURL  -Method GET -ContentType 

Open in new window

1
I have an OData query to get a historical list of HDX sessions (username, start/end times, protocol, Delivery Group) from Director. What's the easiest way to extract the data from the XML and produce a simple table of the fields above? I tried using Chrome's Advanced REST Client, but while the XML response came back fine, the client couldn't parse it successfully.
The actual query:
http://ddc.company.com/Citrix/Monitor/OData/v3/Data/Sessions?$filter = StartDate ge datetime'2018-12-02T15:14:49' and StartDate le datetime'2018-12-03T03:14:49' and CurrentConnection/Protocol eq 'HDX'&$select = StartDate,EndDate,CurrentConnection/Protocol,Machine/DesktopGroup/Name,User/UserName,User/FullName&$expand = CurrentConnection,Machine/DesktopGroup,User 

Open in new window

0
I am receiving this error on my production "serverSQL Server failed to communicate with filter daemon launch service  (Windows error: The service did not start due to a logon failure.
). Full-Text filter daemon process failed to start. Full-text search functionality will not be available."

I know how to add and or change the password on the login tab of the properties of the service.   But the username for this service is an NT Service account and with the Admin account, I seem not to be able to have access to change the password on this account.  So I have just three questions. (I think)

1) Why would this happen to an NT user account?
2) Can I change the password on an NT user account?
3) If I cannot change the password, would it be possible to just use a domain user account, like the rest of the SQL services are using or do I have to use the NT account for this Service?

Thanks,

Rich
0
How do we receive list of docs number while calling Web API client.

I am getting error : "Status Code: 406, ReasonPhrase:Not Acceptable',....

But, the service is correct and all other remaining values are correct. but, finally we are getting the error.

Scrrenshot attached for reference (Status Code).

Source is below:
------------------------

 	    
	    private const string URL = "http://testURL.net/getDocs";
            private const string DATA = @"{""EmpId"": ""101"",""EmpName"": ""ANDREWS"",""Dept"": ""Accounts""}";
	    System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
            client.BaseAddress = new System.Uri(URL);
            byte[] cred = UTF8Encoding.UTF8.GetBytes("username:password");
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(cred));
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));

            System.Net.Http.HttpContent content = new StringContent(DATA, UTF8Encoding.UTF8, "application/x-www-form-urlencoded");
            HttpResponseMessage messge = client.PostAsync(URL, content).Result;
            string description = string.Empty;
            if (messge.IsSuccessStatusCode)
            {
                string result = messge.Content.ReadAsStringAsync().Result;
                description = result;
            }

Open in new window


What is the problem in the above code..? How do we receive the list of doc numbers..?
StatusCode.png
0

REST

312

Solutions

608

Contributors

Representational state transfer (REST) is an architectural style that gives a coordinated set of constraints to the design of components in a distributed hypermedia system used to design networked applications. RESTful systems typically communicate over Hypertext Transfer Protocol (HTTP) with the same HTTP verbs (GET, POST, PUT, DELETE, etc.) that web browsers use to retrieve web pages and to send data to remote servers. REST interfaces with external systems using resources identified by Uniform Resource Identifier (URI) that can be operated upon using standard verbs.

Related Topics

Top Experts In
REST
<
Monthly
>