REST

367

Solutions

665

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

Hi,
I created a model with Entity Framework which has one SQL table.  Thus, so far I have this model that Entity Framework created with the changes I made.  

Now I would like to do a change and include a new table I added to the database, but I am not being successful with it.  I use the option "Update Model from Database" and then the ADD tab, and it works.  Although it replaces the content of the pre-existing class model with one from scratch and therefore it gets rid of all attributes and other things I added.  

I researched an answer but I did not find a successful one.  The most valid answer I researched seemed to be the one pointing at creating a partial class.  If this is the correct route I have no idea on how to about it.  How do I create it?  Under what folder do I save it?  How do I connect it to the database?  What code do I put in it?

So, the question of this posting is: how can I add/link the new table to Entity Framework and keep all the rest as it is now?  Please provide a step by step example/scenario with all details as I am new to this.  Thank you very much for your help.
0
Learn Ruby Fundamentals
LVL 19
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

I've got that endpoint from my backend developer http://localhost:8080/wordsw-service/code/lookup?searchTerm=011

I'm a frontend dev and new to graphql and I need to use graphql with that and passing search term (which is the code which user will type) as an argument in graphql resolver, fetching data from the above adress words but if I remove search query(so on graphql server I fetch http://localhost:8080/wordsw-service/code/lookup ) I get an error from below. I guess he locked the usage of that endpoint without search query as the message says             "message": "Required String parameter 'searchTerm' is not present",
should I ask him to unlock it or is there a way to use that kind of endpoint which contains search query on graphql search? I think the whole point of graphql is to avoid using query parameters

{
  "errors": [
    {
      "message": "400: Bad Request",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "clinicalCodes"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "response": {
          "url": "http://test-java.volta.iplato:8080/dictionary-service/readcode/lookup",
          "status": 400,
          "statusText": "Bad Request",
          "body": {
            "timestamp": "2019-10-30T18:55:34.784+0000",
            "status": 400,
            "error": "Bad Request",
            "message": "Required String parameter 'searchTerm' is not present",
 

Open in new window

0
I have a rest query and I am trying to get a field from the list to be the "Title" and another field to be the URL of the Title. My code is not working.

tableContent += '<span>''<a href='"+objItems[i].bookURL+'">"+objItems[i].Title+"</a>'</span>;

Open in new window

0
I have a REST Query to my SharePoint list.  I am displaying the results in a custom table.  The problem is the data repeats.  It seems like 5 times, but maybe it keeps repeating.  Here is my code.

$(function(){
    $("#btnClick").click(function(){
        var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('ListName')/items?$select=Title%2CName%2CURL&$top=100";
           $.ajax({
              url: requestUri,
              type: "GET",
              headers: {
                  "accept":"application/json; odata=verbose"
              },
              success: onSuccess,
              error: onError
});

Open in new window

0
I have a list with 3 columns.  Title, Header, Url . I would like to pull those values using the REST API and create 3 columns.  The Titles are URLs from the URL column.  I would be like this:

List:
Header           Title              Url
Company 1    Title               Url
Company 1    Title               Url
Company 1    Title               Url
Company 1    Title               Url
Company 2    Title               Url
Company 2    Title               Url
Company 2    Title               Url
Company 3    Title               Url

HTML via Javascript

Company 1        Company 2        Company 3
Title                      Title                      Title
Title                      Title
Title                      Title
Title
0
Hi All,

Hope your well,

I have a VB script which is nearly there but just a small part missing.

The script is being configured to delete certain contacts with a particular attribute set. Within that subset of contacts with this particular attribute im also adding some additional logic to not delete all of them e.g.

as an example: I look for contacts with extensionattribute1 set with "SPECIALATTRIBUTE", I then say, if email address 2 is populated DO NOT DELETE, move on to the next. My aim is to delete all of these contacts without an email address 2 set. The bit where im stuck is that I'm also trying not to delete contacts that have a certain domain e.g outlook.com but im not sure on the contains context. My ultimate goal is to look for contacts with a particular attribute, keep the ones that have an Email2address set and if their email1address contains outlook.com and then delkete the rest that do not match these conditions.


Set objRecord = objItem.Find("[Extensionattribute1] = ""SPECIALATTRIBUTE""")

While Not objRecord Is Nothing
      
      If objRecord.Email2Address = "" And objRecord.Email1Address <> "*OUTLOOK.com" Then objRecord.Delete

      Set objRecord = objItem.FindNext

Many Thanks.
0
I have a perl script that is doing a REST call to a server .  The REST call is working as designed.  I now have to enforce TLS 1.2 for that REST API call in the perl script but I do not know what I have to modify.  Any help would be appreciated.

I have until 10/30/2019 to fix as the server receiving the REST call will begin to refuse TLS 1.0 connections.
0
Hi experts,

I am trying To design a golang set of REST api to connect different applications to a single api endpoint.

Basicaly, i would like users to login once on the first api call (user to golang), and then use my go code to pass authentication To backend application that are also connected To keycloak.

Does anyone have experience / example / flows that match my needs ?

Best Regards.

Grégoire
1
I have a thirdparty rest api and angular js frontend project that I inherited.

data is in json, and the code iterates over the collection and displays it.
as I don't have control over the api and what it returns , I want to hide certain items in the collections.

what are my options in angularjs?
0
Hi Experts,

I am facing the below issue while hitting the REST service request from soapui.
java-1.8
soapui-5.5.0

Exception:
exception in thread "main" java.lang.assertionerror: failed generating bytecode

used below link for sample:
https://www.soapui.org/rest-testing/getting-started.html


Suggest me how to resolve this issue.
0
Fundamentals of JavaScript
LVL 19
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Hi Experts!

I have been using DataSnap REST for some weeks but I have problems understanding some concepts related to TJSONObject and how these data are sent.
I have three related questions.
I consider a simple class:


TMyclass = class
  private
    [JSONName('name')] // invio
    Fname: string;
    [JSONName('surname')] // invio
    Fsurname: string;
    [JSONName('mytext')] // invio
    Fmytext: string;

    procedure Setname(const Value: string);
    procedure Setsurname(const Value: string);
    procedure Setmytext(const Value: string);
  public
    property name: string read Fname write Setname;
    property surname: string read Fsurname write Setsurname;
    property mytext: string read Fmytext write Setmytext;
  end;
  
.....

procedure TMyclass.Setname(const Value: string);
begin
  Fname := Value;
end;

procedure TMyclass.Setsurname(const Value: string);
begin
  Fsurname := Value;
end;

procedure TMyclass.Setmytext(const Value: string);
begin
  Fmytext := Value;
end;  

Open in new window


.....

In my code I have something similar to:

Procedure TMain.Send_JSON;
var
   VJSONObject: TJSONObject;
   VMyclass:TMyclass;
begin
   VMyclass:=TMyclass.Create;

   VMyclass.name:='John';
   VMyclass.surname:='Ace';
   VMyclass.mytext:='';

   VJSONObject:=TJson.ObjectToJsonObject(VMyclass);
   //...
   
   RESTClient1.ResetToDefaults;
   RESTRequest1.ResetToDefaults;
   RESTResponse1.ResetToDefaults;
   RESTClient1.BaseURL:='http://111.222.333.444:8080/datasnap/rest/mypath';
   RESTRequest1.Timeout:=RESTRequest_Timeout;
   
   RESTRequest1.Resource:='/MyParam'; 
   RESTRequest1.Method:=TRESTRequestMethod.rmPOST; 
   RESTRequest1.AddBody(VJSONObject.ToJSON, ContentTypeFromString('application/json'));
   //...
   RESTRequest1.Execute;
   //...
end;

Open in new window



[First question]
When I send this JSON:
         {"name":"John","surname":"Ace","mytext":""}
i don't want to have:
"mytext":""
in the JSON.

[Second question]
I don't know a way to insert a JSON array like this:
{"name":"John","file": [{"name_file":"myfile1.txt","dir_file":"C:\mydir"},{"name_file":"myfile2.txt","dir_file":"C:\mydir2"},...]}

[Third question]
I am looking for a method to manipulate the:

VJSONObject.ToString

before insert in the:

RESTRequest1.AddBody(VJSONObject.ToJSON,...

but I couldn't find it. I search something like:

  VJSONObject := Json.StringToJsonObject(VJSONObject.ToString);

I have a lot of problems because there is no documentation on this part.
Does anyone have a solution?


Working with RAD Studio Tokyo 10.2.3
0
HI,
I have a question about rest call.  I have a rest call, which with token, but I got a status code :999. why it will return 999?
There is no response come back.

Thanks
0
I'm working on an old angular project,
in one of my HTML page I have  this,

<tr class="abc" data-ng-repeat="items in vm.products">

this iterates through the item in the product list , return by the rest call , by the looks of it. I wanted to sort it by a particular data field.

so if the rest calls return json data as such
{
   id: ...
   name : ...
   price : ...
   quantity : ...
...
}

to sort it by price, can just change the code to --> data-ng-repeat="items in vm.products | orderBy:'price' "

just adding this to HTML page, didn't work.

do i have to change any other code for this?
0
Hello everyone. I am trying to build a soap/rest webservice using Yii2. I cannot figure out how to route to the specific controller depending on the url.
It should work as follow:

For REST:
url: http://mydomain/rest/service/v1/action/param1/param2/...
responseType: JSON

For SOAP:
wsdl: http://mydomain/soap/service/v1/?wsdl
url: http://mydomain/soap/service/v1/
responseType: XML

I have many services published using my own implementation but I would like to use yii2.

Do you have any idea?

Thanks in advance

I have seen that adding this to yii configuration will do the trick (at least for REST):

 'rules' => [
                [
                    'class' => 'yii\rest\UrlRule',
                    'controller' => ['rest'],
                    'pluralize' => false,
                    'extraPatterns' => [ ],
                ]
],

Open in new window

0
I am trying to integrate a carousel that can be used / controlled with swipe gestures: Swiper.

This is how the page structure looks like:

<!-- Swiper -->
  <div class="swiper-container">
    <div class="swiper-wrapper">
      <div class="swiper-slide">Slide 1</div>
      <div class="swiper-slide">Slide 2</div>
      <div class="swiper-slide">Slide 3</div>
      <div class="swiper-slide">Slide 4</div>
      <div class="swiper-slide">Slide 5</div>
      <div class="swiper-slide">Slide 6</div>
      <div class="swiper-slide">Slide 7</div>
      <div class="swiper-slide">Slide 8</div>
      <div class="swiper-slide">Slide 9</div>
      <div class="swiper-slide">Slide 10</div>
    </div>
    <!-- Add Pagination -->
    <div class="swiper-pagination"></div>
  </div>

  <!-- Swiper JS -->
  <script src="../dist/js/swiper.min.js"></script>

  <!-- Initialize Swiper -->
  <script>
    var swiper = new Swiper('.swiper-container', {
      pagination: {
        el: '.swiper-pagination',
        dynamicBullets: true,
      },
    });
  </script>

Open in new window


As I am using jQuery to retrieve the data from the server. Once the document has loaded, I collect all the items from the server using a REST API call, I generate the <img> tags with the appropriate src (location of the picture) and then I put them all into an array called allWidgetPictures[].

I use the following function to update the DOM:

      /**
       *@description Retrieves all picture URL for the carousel function
       */
      this.retrieveAllWidgetPictures = function() {
        for (i = 0; i < app.allWidgetPictures.length; i++) {
          console.log(app.allWidgetPictures[i] );
          $("#swiper-wrapper").after(app.allWidgetPictures[i] );
          
        }

      };

Open in new window


Is there anything else that I need to do in order to update the page, as the <img> tags do not appear after the <div swiper wrapper>.
The array is properly populated:

Annotation-2019-05-29-013803.png
Am I missing anything or why is the page not updated with all the <divs>?
0
I need a way of pulling car trade-in values from kbb.com or some other source into this Google spreadsheet https://docs.google.com/spreadsheets/d/19x5gqcy-9CCaoguq5aFOlY-W1P7H6HaqYxjp3PQLoAM/edit#gid=288072689.
0
Hi Experts,

How can I give a user permissions to one VM in Hyper V without giving them local admin or Hyper V administrator access to the rest of the virtual?  So far the options to do this I am finding our outdated or I'm not seeing those options.

We have 1 Hyper V server, not clustered.
2016.

Thank you,

Karen
0
Hi,

I want to wrap a lambda function, which sets DesiredCapacity to 0, to a Rest API.

This is my lambda - it works fine

exports.handler = (event, context, callback) => {

  const AWS = require('aws-sdk');
  var autoscaling = new AWS.AutoScaling();

  var paramstestpdf = {
    AutoScalingGroupName: "awseb-e-ygxcpvxwv5-stack-AWSEBAutoScalingGroup-xxxxxxxx", 
    DesiredCapacity: 0, 
    HonorCooldown: true
  };
  
    var paramstestsched = {
    AutoScalingGroupName: "awseb-e-mnq4mpfjuw-stack-AWSEBAutoScalingGroup-xxxxxxxx",
    DesiredCapacity: 0, 
    HonorCooldown: true
  };
  
      var paramstestcloudagent = {
    AutoScalingGroupName: "awseb-e-2mhm4z3amt-stack-AWSEBAutoScalingGroup-xxxx",
    DesiredCapacity: 0, 
    HonorCooldown: true
  };
  
     var paramstestnotifications = {
    AutoScalingGroupName: "awseb-e-sjppyxakq2-stack-AWSEBAutoScalingGroup-xxxxx",
    DesiredCapacity: 0, 
    HonorCooldown: true
  };
  
    var paramstestnode = {
    AutoScalingGroupName: "awseb-e-fwyg2xkzqq-stack-AWSEBAutoScalingGroup-xxx",
    DesiredCapacity: 0, 
    HonorCooldown: true
  };
  autoscaling.setDesiredCapacity(paramstestpdf, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else     console.log(data);           // successful response
  }
  );
  
    autoscaling.setDesiredCapacity(paramstestsched, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else     console.log(data);           

Open in new window

0
In AWS we have Lambda code and rest of the project is using AWS Glue code. Now, I need to have 2 Jenkins configurations in one yaml file one is for lambda and one is rest of the project. How can i achieve this?

Deployment script for Serverless and rest of the project in single yaml file with two different Jenkins configurations.

Thanks in advance.
0
Bootstrap 4: Exploring New Features
LVL 19
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

We use exchange 2013

We have mailbox say “mailbox1”.

About 30 people have access to mailbox1.
Say one of user who got access to mailbox1 is John.

When John sends email on the behalf of mailbox1 the actual email goes to sent items folder of John in outlook.
We are trying to find the way so when John sends email on the behalf of mailbox1 it goes to sent items folder of Mailbox1(not John).
And we want to apply same for rest of users we got access to Mailbox1

Is this possible?

We have limitation that outlook can’t be used on “cached exchange mode” because user access outlook via Citrix.
0
Experts,
 We have sharepoint 2013 environment. We have one custom Access Denied page where i added javascript code to check current user is part of group or not. I am getting userid from"_spPageContextInfo.userId" and use below rest api code to access username.

var ctx = new SP.ClientContext.get_current();
        this.web = ctx.get_web();
        this.currentUser = this.web.get_currentUser();
alert(currentUser);
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
});

Open in new window


Now when user does not have permission for that page and access then it's read the user id but it's authenticate fail for rest api.  Below is the error message.

 HTTP401: DENIED - The requested resource requires user authentication.
(XHR)GET - http://server/_api/web/getuserbyid(47)

How to resolve this problem? I want to read current username from that page. Is there any way that rest api will not fail?
0
I have a service which has a REST endpoint which returns a simple LIST containing Events and the event descriptions. I have been asked to return the output in standard JSON format. Is this just a matter of adding , RequestFormat = WebMessageFormat.Json &    ResponseFormat = WebMessageFormat.Json to the operation contract or is there more to it than this ?
0
I'm trying to set up an SSL endpoint on my server (Windows Server 2012 R2) so that it can receive https POSTs from an external server. I am using a simple REST framework for Powershell called RestPS: https://github.com/jpsider/RestPS to listen on port 8089 and I have an SSL certificate that I'm trying to use but I am getting errors when I try to use it. I'm very much a novice with SSL certificates and need some help. When I run Start-RestPSListener in Powershell, I get these messages:

SSL Certificate deletion failed, Error: 2
The system cannot find the file specified.

SSL Certificate add failed, Error: 1312
A specified logon session does not exist. It may already have been terminated.

Starting: https:// Listener on Port: 8089

Open in new window


I'm not sure what those errors mean or if they matter. But something isn't right because when I try to POST from the external server I get an 'unknown SSL protocol error' connecting to my server.

I've looked at the certificate stores using the MMC and there's a bunch of stuff in there, but it's all very confusing to me.

Not sure if this is related: I'm also running Apache on this server, and it is listening on port 443 using the same SSL certificate. It is working fine and receiving POSTs.

Also, here's what I'm getting from the external/remote server trying to POST to my server:

 Trying <<ip address>>...
Name '0.0.0.0' family 2 resolved to '0.0.0.0' family 2
Local port: 0
Connected to <<domain name>> (<<ip 

Open in new window

0
Hi,
 We have sharepoint list view where user filter and sort data. Now we would like get sorting and filter parameters and generate rest api url by script editor to fetch some list items. is it possible to read filter and sorting parameter by url or ctx object?

There is a object ctx.ListData.Filterlink gives some parameters but it's in another format.

"?FilterField1=LinkTitle&FilterValue1=A&SortField=LinkTitle&SortDir=Asc&PageView=Shared&"

Here is the REST Api url where i need to add filter and sorting parameters.
 url: siteUrl + "/_api/lists/getbytitle('Test_Custom_List')/Items?$select Title",



 <script>
var siteUrl = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;
 
jQuery.ajax({
  // need to generate dynamic url based on filter and soting on page
    url: siteUrl + "/_api/lists/getbytitle('Test_Custom_List')/Items?$select Title",
    type: "GET",    
    headers: { 
        "accept": "application/json;odata=verbose",
        "content-type":"application/json;odata=verbose",
        "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
    },
    success: function(d) {
        var stringData = JSON.stringify(d);
        var jsonObject = JSON.parse(stringData);
        var results = jsonObject.d.results;
        for(i = 0; i < results.length;i++) {
            console.log(results[i]["Title"])
        }
    },
    error: function() {
        console.log('fail');
    }
});
</script>

Open in new window

0
Please reference the solution to my previous question:

PowerShell:  Move from using arrays/looping into objects/pipelining

This has been working on the inital data sets but these were quite small.  Now that the QA team is actually loading devices, the script fails to write the results to the file.  Here is the current code:
# Get all mobile devices from JAMF
$JAMFfile = $FilePath + "\JAMF_Prod.csv"

$BaseURL = "https://" + $JAMFAPIServer + "/JSSResource/mobiledevices"
$Header = @{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($JAMFAPIUser+":"+$JAMFAPIPassword))}
$Type = "application/json;charset=UTF-8"


Try 
{

    $MobileDeviceResponse = Invoke-Restmethod -Uri $BaseURL -Method GET -ContentType $Type -Headers $Header
    $MobileDeviceResponse.mobile_devices.mobile_device |
        Select-Object -Property name, 
                         id,
                         serial_number,
                         model,
                         @{n="department";e={ 
                                (Invoke-Restmethod -Uri "$BaseURL/id/$($_.id)/subset/location" -Method GET -Headers $Header).mobile_device.location |
                                 Select-Object -ExpandProperty department}},
                         @{n="building";e={ 
                                (Invoke-Restmethod -Uri 

Open in new window

0

REST

367

Solutions

665

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