Go Premium for a chance to win a PS4. Enter to Win

x

REST

195

Solutions

401

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

what are advantages of creating a REST service in Web API vs some other technologies in .NET like WCF, ASP .NET MVC etc.
0
Industry Leaders: We Want Your Opinion!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

I have a groovy script that makes an API call to a rest api and it gets a result. The problem is that I need to sent a file instead of a URL for the final requirements. I am not sure how to do that.

So, I need to change:
FROM: map["file_url"] = "https://i.ytimg.com/vi/JPA_rzHDy6o/maxresdefault.jpg"
TO: map["file"] = "@Nda.pdf"

I think this is a much more difficult situation, to send a file instead of a URL. I would suspect, it starts out trying to understand the def client = HttpClientBuilder.create().build() and how this api supports sending a file.

Any pointers on how to do this?

I also suspect that post.addHeader("content-type", "application/json") may not work and instead another header may have to be used. Perhaps multipart/form-data.



Script that works


import groovy.json.JsonSlurper


@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.5.2')

import groovy.json.*

import org.apache.http.client.methods.*
import org.apache.http.entity.*
import org.apache.http.impl.client.*



def map = [:]
map["message"] = "Hi There"
map["title"] = "Title"
map["subject"] = "sub"
map["test_mode"] = "1"
//map["file"] = "@Nda.pdf"
map["file_url"] = "https://i.ytimg.com/vi/JPA_rzHDy6o/maxresdefault.jpg"
map["signers"] = [name: 'bob', email_address: 'ed_fletcher@aol.com']

def jsonBody = new JsonBuilder(map).toString()
println jsonBody


def url = 'https://APIKEYHERE:@api.hellosign.com/v3/signature_request/send'
def …
0
In jquery, is it possible to find element then get the rest of the nodes(outside of original element)?
E.g.

If i pass you BondName = abc and if it is found, then output me everything within <additionalInformation>?

 <Surety>
  <SuretyLine>
   
    <Commercial>
      <Bond>
		<General Information>
		<BondName>abc</BondName>
   		</General Information>
		<AddtionalInformation>
          		<div class="col-lg-12">
           		 <Input Type="text" Name="additionalInfo_licenseNo" ID="additionalInfo_licenseNo" Onchange="fnSaveSingleData(this.name,'1')" Placeholder="Enter License No." 				Class="form-control" Title="License is required!" PrefillValue="No" Required="" />
          		</div>

        	</AddtionalInformation>
      </Bond>
       <Bond>
	<General Information>
		<BondName>xyz</BondName>
   	</General Information>
	<AddtionalInformation>
          <div class="col-lg-12">
            <Input Type="text" Name="additionalInfo_licenseNo" ID="additionalInfo_licenseNo" Onchange="fnSaveSingleData(this.name,'1')" Placeholder="Enter License No." Class="form-control" 		Title="License is required!" PrefillValue="No" Required="" />
          </div>
        </AddtionalInformation>
      </Bond>
    </Commercial>
  </SuretyLine>
</Surety>

Open in new window

0
Haven't been here in a while.

I am trying to setup the highlight selected record in a continuous form.  Each record has a [delete] button and a [Appt_ID] box.

There is a txtActiveRecord box in the header.  The Delete_OnClick event sets "Me.txtActiveRecord = Me.txtAppt_ID" as the first item in the procedure.  CF then kicks in on "expression is: [txtAppt_ID]=[txtActiveRecord]"  and sets one of the controls to a particular colour. The rest of the On_Click event asks the user "are you sure" etc, and if clicked "No", it all returns to normal.

This works perfectly, EXCEPT the CF doesn't kick in until after the procedure is completed.  i.e. too late.  

However, when I step through the event line by line, the CF kicks in right on cue.  i.e. a the "Me.txtActiveRecord = Me.txtAppt_ID" line.

Where have I gone wrong?

Cheers,
Brodie
0
hello
currently i am returning like below from my asp.net wb api
{
  "emplyoees": [
            {
                "empid": "3301",
                "empname": "John"
                },
 {
                "empid": "3991",
                "empname": "Marty"
                }
                ]
            }
        

Open in new window

i do not want to return key name "employees".
i want some thing like this:
{
   [
            {
                "empid": "3301",
                "empname": "John"
                },
            {
                "empid": "3991",
                "empname": "Marty"
                }
            ]
            }

Open in new window

here is my model classes
 public class EmployeesResponse
    {


      public   Employee[] Employees;
     }
 public class Employee
    {
        public string empid{ get; set; }
        public string empname{ get; set; }
}

Open in new window

0
Hello guys,

I'm designing a letterhead, i want the first page to have a design while the rest of the document to have a different design (Different header, different margins) all works well so far, my only issue is that i want to be able to paste a document into this letterhead, and the first page will have different layout than the rest of the pages.  

I've added a "section break ( continuous)" but when i paste my documents, the rest of the pages change to the design its supposed to change to but doesn't keep the margin needed, and that's because all the text comes before the "section break" i've added

Is there a chance to lock that section Break to the first page only and the extra text goes to the second page and adapt to its style.

Thank you
BEN
0
Currently I pull Goformz data using Excel VBA code which looks like the code below which works fine.

' Get Rest API Data from Goformz
Dim strUserName As String
Dim strPassword As String

strUserName = ""
strPassword = ""

Dim http As Object, JSON As Object, i As Integer
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", "https://api.goformz.com/v2/formz?" & "status=draft" & "&filter=lastupdateddate%20gt%20" & Sheets("Values").Range("B7") & "%20and%20lastupdateddate%20lt%20" & Sheets("Values").Range("B8") & "&pagesize=" & Sheets("Draft Forms").DraftFormsComboBox1.value & "&pagenumber=" & Sheets("Values").Range("PageNumber").value & "&sort=lastupdateddate%20desc", False
http.setRequestHeader "Authorization", "Basic " & Base64Encode(strUserName & ":" & strPassword)
http.send
Set JSON = ParseJson(http.responseText)
i = 5
For Each Item In JSON
Sheets("Draft Forms").Cells(i, 1).value = Item("status")("status")
Sheets("Draft Forms").Cells(i, 2).value = Format(DateAdd("h", 11, Replace(Left(Item("lastUpdateDate"), 19), "T", " ")), "dd/mm/yyyy hh:mm:ssam/pm")
Sheets("Draft Forms").Cells(i, 3).value = Item("templateId")
Sheets("Draft Forms").Cells(i, 4).value = Item("templateUrl")
Sheets("Draft Forms").Cells(i, 5).value = Item("name")
Sheets("Draft Forms").Cells(i, 6).value = Item("url")
Sheets("Draft Forms").Cells(i, 7).value = Item("assignment")("url")
i = i + 1
Next
     
Sheets("Draft Forms").Range("A4").value = "Status"
Sheets("Draft Forms").Range("B4").value = 

Open in new window

0
Dear All

I am using WebClient.DownloadFile() to download  a text(*.txt) file from server. It was working fine in all systems since years but suddenly in two systems it started giving issues though in rest of the systems its working fine.
Issue is its downloading an empty file from server and getting hang.

Please suggest what could be the reason. Below is the line of code I am using to download the file.

                           using (WebClient wc = new WebClient())
                            {
                                try
                                {
                                    wc.Credentials = System.Net.CredentialCache.DefaultCredentials;
                                    wc.Proxy = null;
                                    wc.DownloadFile(ServerURL + ServerFileName, CurrentDir + ServerFileName);
                                    wc.Dispose();
                                    
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ServerURL + ServerFileName+Environment.NewLine+ex.ToString());
                                }
                           }

Open in new window


Thanks in advance.
0
I need to write a piece of JavaScript which will make a REST call to update a field within a document library InfoPath (XML) document.

Any help on this would be greatly appreciated.
0
Hi there!

I have a development written in .NET/C# standard (not .NET Core) that connects to a Rest API for fetching records of my customer's business. In other to login I have automated sending login form using NHtmlUnit, when I get an authorization token, I use RestSharp for fetching the data. The program runs well when I run on my development machine, however, when I deploy the the production environment (in this case, Azure), I get the following exception exception:

[10/04/2017 03:00:31 > 60fd26: INFO] An error occurred authenticating with Exact token info.

[10/04/2017 03:00:31 > 60fd26: INFO] The AddressFamily InterNetwork is not valid for the System.Net.IPEndPoint end point, use InterNetworkV6 instead.

[10/04/2017 03:00:31 > 60fd26: INFO] Parameter name: socketAddress

[10/04/2017 03:00:31 > 60fd26: INFO]    at java.net.AbstractPlainSocketImpl.doConnect(InetAddress , Int32 , Int32 )

[10/04/2017 03:00:31 > 60fd26: INFO]    at java.net.AbstractPlainSocketImpl.connectToAddress(InetAddress , Int32 , Int32 )

[10/04/2017 03:00:31 > 60fd26: INFO]    at java.net.AbstractPlainSocketImpl.connect(SocketAddress , Int32 )

[10/04/2017 03:00:31 > 60fd26: INFO]    at java.net.PlainSocketImpl.connect(SocketAddress , Int32 )

[10/04/2017 03:00:31 > 60fd26: INFO]    at java.net.SocksSocketImpl.connect(SocketAddress , Int32 )

[10/04/2017 03:00:31 > 60fd26: INFO]    at java.net.Socket.connect(SocketAddress endpoint, Int32 timeout)

[10/04/2017 03:00:31 > 60fd26: INFO]    at

Open in new window

0
Free Tool: Port Scanner
LVL 11
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Hi,

Someone (stupidly) installed virtual machines on our mail server, hence creating unwanted virtual addresses to that server - this meant every time a quarry for mail.ourdomain.com happned internally there would be a long wait time till clients would get the actual one that works - we've fixed this & removed the A records that were created because of this but one of the DCs which is also a DNS server refuses to remove these addresses and states "The record cannot be delete. Refused." - in that cullomn by the way under "Time stamp" for these records it says "Static".

What can we do? we've gone through all the rest of the servers & these records no longer appear there..

Thanks in advance!
1.JPG
2.JPG
0
Hello,
facing a problem to choose best client side framework for localization with jsp?
I have REST API which i need to consume at client side and display it on jsp will it be safe to use spring mvc for client side?
What is the best practice to integrate client-server ?
0
I have been teaching a colleague how to create org charts on our own machines. When showing her how to rearrange subordinates,  each time she selects a subordinate pattern with the connectors on the left hand side 2 things happen:
1. the 1st subordinate does not arrange as the rest it's arrow is always bent and forms a different pattern into the manager
2. the distance from the connectors to the shapes is very large
However if she selects any patterns with the connectors on the right of the shapes she gets what I get, and what I expect, uniformity and a tighter space.
We are both using 2016. Please advise. This is her first introduction to Visio so her software is straight out of the box so to speak.
Any ideas gratefully accepted
0
windows 7 and 2008 R2 standard.
i'd like for users to have local profiles on their main computer they use 95% of the time. but then still be able to roam once in a while and use other computers. is that possible? thanks
0
I'm trying to implement Rest API for BFM(BargainFindermax) in my project where SOAP calls are already implemented and working. Since Soap does not provide pagination options, I was trying to implement the same flight search functionality with REST "BFM" API.

After integrating the Rest calls through javascript http.post request, Rest calls are working but the returned results in REST "BFM" call are fewer than SOAP "BFM" call. Fare prices returned in REST call are expensive compared to soap results as well. The request body of REST call is exactly same as SOAP i.e. Cabin type, passenger details, origin/destination information, currency etc. are all forming just as it was in previously implemented SOAP call. REST Call does not seem to return any record against "SisterOriginMilage.Number" either.

For some reason, Rest BFM returns different, fewer and costly Itinerary results than SOAP BFM. Any idea what could be the reason for these different results? Any help would be much appreciated.
0

Below is my code.
Web-sphere context path is set to simple slash /.

xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
 version="3.0">
 <servlet>
    <servlet-name>RestServlet</servlet-name>
    <servlet-class>javax.ws.rs.core.Application</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>RestServlet</servlet-name>
    <url-pattern>/users/*</url-pattern>
</servlet-mapping>
</web-app>

Open in new window



appln

package com.ibm.jaxrs.sample;

import java.util.HashSet;
import java.util.Set;

import javax.json.JsonWriter;
import javax.ws.rs.ApplicationPath;

@ApplicationPath("/users")
public class HelloWorldAppConfig extends javax.ws.rs.core.Application {
	   
	   public Set<Class<?>> getClasses() {
	      HashSet<Class<?>> set = new HashSet<Class<?>>();
	      set.add(HelloWorldResource.class);
	      System.out.println("Completed application getclasses");
	      return set;
	   }

}

Open in new window



resource

package com.ibm.jaxrs.sample;

import javax.ws.rs.core.*;
import javax.ws.rs.*;
import javax.servlet.http.HttpServletRequest;

import javax.ws.rs.core.Application;

@javax.ws.rs.Path("/show")
public class HelloWorldResource {

	private static final String LINK_SELF = "self";
	public HelloWorldResource() {
		// TODO Auto-generated constructor stub
    	System.out.println("Got inside constructor");
	}
	
	@GET
	@POST
    @Produces(MediaType.TEXT_PLAIN)
	@Path("/show")
    public Response getAll(@Context UriInfo uriInfo) {
		System.out.println("Completed application getsingleton");
        return Response.ok("Hello").build();
    }//@Produces( MediaType.APPLICATION_JSON )
	
 }

Open in new window



included jars in WEB-INF\lib foler


com.ibm.jaxrs2.0.thinclient_9.0.jar
com.ibm.jaxws.thinclient_9.0.jar
com.ibm.ws.ejb.portable_9.0.jar
com.ibm.ws.ejb.thinclient_9.0.jar
com.ibm.ws.jaxrs20.tools.jar
cxf-rt-frontend-jaxrs-3.1.12.jar
cxf-rt-rs-client-3.1.12.jar
cxf-rt-rs-extension-providers-3.1.12.jar
cxf-rt-rs-extension-search-3.1.12.jar
cxf-rt-rs-json-basic-3.1.12.jar
javax.ws.rs-api-2.0.jar

Open in new window

0
I dont want to re-invent the wheel and build a new WCF or Rest webservice. Please advise, how can I find out if the service I need has already been created by someone? I would love to be able to re-use that WCF/Rest service.

Example: I need a service that would convert currencies.

Thanks,
Ricky
0
I have a web part page displaying 5 web parts. Four of the web parts (Efforts, Phases, Capture Points & Areas) are "provider" web parts, and come from lists that are the sources of 4 lookup columns in the 5th "consumer" web part (Lessons Learned).

The provider web parts are displaying the Title column from the lists.

The Using Javascript/jQuery, I "connected" the 4 provider web parts to the consumer web part, such that when you click on a Title column value, the consumer web part is filtered to show only those records that have the clicked value in the relevant metadata column.

All that is working very nicely.

Now, my requirement is to go one step further, and display the number of items that will be displayed if you click on a Title column value in any of the 4 web parts. If there are none, a "0" should be displayed.

I've constructed a lists service query that successfully returns the number of items that exist for a given, hard-coded, metadata value:
[SiteURL]/_vti_bin/listdata.svc/[ListName]/$count?&$filter=Effort/Title eq 'AAA'

So, the goal is to display such an item count beside the corresponding provider web part value, such as:
Efforts web part:
AAA (10) //assuming there are 10 items in the consumer web part tagged with Effort 'AAA'

Now, I'm bumping up against the current limit of my abilities.

I know that I need code (javascript, rest, ajax, json) for each provider web part with looping to cycle through all of the TD cells that have …
0
I'm trying to implement a restful architecture using .NET Core based on HATEOAS.

For that, I would be using an include parameter with a list in the GET requests so as to include the entities related to the parent.

For example, if I want to get a master (master/details) with the related client I would perform the following GET request:

GET http://api.com/master/id=1?include=Client

Open in new window

If the include clause is not there, the related client in the master will only show the link to get it.

The will happen with every related entity.

What I'm trying to find out is the best way to implement this in my base resource's class.

The solution I applied is to use a base class using generics:

public class InstanceResource<T> where T : BaseResource
{
    public string Href { get; set; }

    public string ClassName { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
    public T Object { get; set; }
}

Open in new window

Using this, I will have a Master with a InstanceResource related to it.

The object property of InstanceResource<Client> is the actual Client object. If Client is not included in the Include clause of the GET request, the object will be null and it will only show Href and ClassName.

GET http://api.com/master/id=1?include=Client
{
  "object": {
    "client": {
      "object": {
        "name": "JOHN DOE"
      },
      "href": "http://api.com/client/1",
      "className": "Client"
    },
    "details": {
      "href": "http://api.com/details/masterId=1",
      "className": "Collection<Detail>"
    }
  },
  "href": "http://api.com/master/1",
  "className": "Master"
}

Open in new window

Not included Client:

GET http://api.com/master/id=1

{
  "object": {
    "client": {
      "href": "http://api.com/client/1",
      "className": "Client"
    },
    "details": {
      "href": "http://api.com/details/masterId=1",
      "className": "Collection<Detail>"
    }
  },
  "href": "http://api.com/master/1",
  "className": "Master"
}

Open in new window

As you can see, this approach uses a container class to represent the resource. What I need to know if this solution has any disadvantage.

I saw other solutions where all the properties of the Object are at the same level that Href. Something like this:


Open in new window

0
Free Tool: Subnet Calculator
LVL 11
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

I need to create a set of InfoPath forms and upload them with updated data to a document library.  I have put together some JavaScript which accomplishes this, but the upload of the document (InfoPath doc) is async and the code works fine when I run it in the debugger, but if I run the loop with no breakpoints, the browser hangs on the create/upload of the file.

I am not sure if it is that the function is async or that it appears to be CSOM whereas all my other code is using REST.  

Any help/ideas on this would be greatly appreciated.
0
Hi,

We are developing code in order to do requests to webservices. I am looking  for online webservices that I can use in order to test the next two kind of requests:
- a PUT request
- a request with a HttpHeader

Both SOAP and REST requests.

Anyone a idea for an online application I can use?

Regards,

Arne
0
For two years our vb.net sync app has been running quite successfully hosted on Azure. It gathers recent Db updates and additions from a SQL Db and transposes them on a schedule into the MySQL Db behind a Wordpress site.

The only problem comes when there are two many records to update/add. Then it is prone to either fail or abort in Azure. This happens typically when there are over 500 records to process and the program running time exceeds an hour or two.  We have worked with the Azure team extensively to try and prevent this, but it keeps happening.

We would like to experiment working with the Wordpress REST Api therefore, to see whether time is saved, and efficiency is improved, over the app's current direct SQL calls to the MySQL Db.

The thing is, I'm struggling to find any documentation about how to incorporate the WP REST Api calls in a VB.net application. Does anyone have any examples of how this should be done?

Thank you
0
Dear Sirs,
I have a web app rendering html and exposing at the same time some REST end points.
I have 2 two classes annotated with @ControllerAdvice:
1) A Class will manage all the errors generated on the web side of the application, and redirects to an Error view page
2) The other Class will manage all the errors generated on the REST side of the application and returns an ResponsEntity<Object>

I have some custom exceptions such as NotFoundException, AccessDeniedException, etc.. And there is a generic ExceptionHandler for the Class Exception.class in both the 2 @ControllerAdvice Classes: 1 for web side exception and 1  for REST side exception.

The confusion  I am seeing is that when the generic exception occurs, while I am consuming the REST end points, I will get an HTML error view instead of a Jackson string representing the ResponseEntity<Object> and vice-versa.

How can I handle this. Make @ControllerAdvice Class 1 only look at exceptions generated by all the classes annotated with @Controller, and @ControllerAdvice Class 2 only look at exceptions generated by all the classes annotated with @RestController.


Thanks a in advance
0
Dear sirs,

I have CSRF enabled in my REST application.
I use either RestTemplate or Postman as Client.
How can I set the application in a way that each request (POST/PUT/DELETE) is carried with a token in its header.

I remember using an implementation of  ContainerRequestFilter while working on Jersey, and I could take care of my requests globally.

I am looking forward to hearing from you.
0
I have a user form that is created in extjs framework. The user form has many user fields which are being passed as part of request payload to the REST controller. I am trying to add a grid panel(most likely in a tabular format with multiple rows & columns) to the user form. But I am not sure how to pass the grid panel data as part of request payload to the REST controller. I will post more code if any more details are needed. Any help would be appreciated. Thanks.

Ext.define('soylentgreen.view.admin.UserForm', {
    extend : 'Ext.form.Panel',
    alias : 'widget.userform',
    bodyStyle : 'padding:5px 5px 0',

// some userform elements like firstname,lastname, go here.....

name : 'userTeamGrid',
  xtype : 'gridpanel',
id : 'userTeamGrid',
itemId : 'userTeamGrid',
multiSelect : true,
selModel : Ext.create(
        'Ext.selection.CheckboxModel',
        {
          injectCheckbox : 'first',
          mode : 'MULTI',
          checkOnly : false
        }),
anchor : '100%',
width : '700px',
height : 250,
flex : 1,
store : 'userTeamStore',

var user = form.getRecord();
form.updateRecord(user);
user.save({
        callback : function(records, operation){
          //reset the (static) proxy extraParams object
          user.getProxy().extraParams =  {
            requestType: 'standard'
          }
          if(!operation.wasSuccessful()){
            var error = operation.getError();
0

REST

195

Solutions

401

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.