REST

265

Solutions

524

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

i am trying to print a form which has textboxes and data gridveiw  using Printdocument control, the code below will print the text boxes and first cell of grid view , for the rest of the cells i am getting following  error :
An unhandled exception of type 'System.NullReferenceException' occurred in System.Windows.Forms.dll
Object reference not set to an instance of an object.

 
 private void btnPrint_Click(object sender, EventArgs e)
        {
            printPreviewDialog1.Document = printDocument1;
            printPreviewDialog1.ShowDialog();
        }
e.Graphics.DrawString("Date: "+DateTime.Now.ToShortDateString(),new Font("Arial",12,FontStyle.Bold),Brushes.Black,new Point(20,95));
            e.Graphics.DrawString("Report Number" + txtReportNumber.Text, new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(20, 150));
            e.Graphics.DrawString(@"------------------------------------------------------------------------------------------------------------------------------------------------------",
            new Font("Arial",12,FontStyle.Bold),Brushes.Black,new Point(20,170));
            e.Graphics.DrawString("SN", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(65, 185));
            e.Graphics.DrawString("Reference", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(180, 185));
            e.Graphics.DrawString("Amount", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(480, 185));
 

Open in new window

0
Cloud Class® Course: Microsoft Office 2010
LVL 12
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

I have a PHP REST API, built from this tutorial:
http://www.tutorialsface.com/2016/02/simple-php-mysql-rest-api-sample-example-tutorial/

I need to do these steps in one function and am not sure how to accomplish it.

1. Accept XML Request
2. Respond to request with XML response and 200 status code
3. Send another XML response and 200 status code to a URL parsed from the XML Request


Currently. I have it like this:
function ProAddRq() {

    // If this isn't a POST, respond with 405...
    if($this->get_request_method() != "POST"){
        $this->response('Error code 405, Method not allowed.',405);
    }

    // Get the XML request from input
    $request = file_get_contents("php://input");

    // Get the RqUID from the request
    $xml = @simplexml_load_string($request);               
    $RUID = strtolower($this->xml->xpath("//ProAddRq/RUID")[0]);

    // Build the ACK message CML from the template
    $ack_data = array();
    $ack_data["RUID"] = $RUID;
    $ack_data["PKey"] = "2b3420be-69bf-4bb7-43bb-b632947e236b";
    $ack_data["Status"] = "Accept";

    // using PHP Mustache to render the XML with the values
    $xml_post_string = $this->m->render('../../views/ack' , $ack_data);

    // Call the SendInventory function to send to the URL that is parsed from the $request
    $this->SendInventory($request);

    // set the content_type
    $this->_content_type = 'application/xml';

    // respond with the ACK and 200 response...
    // Setting 

Open in new window

0
Can I replicate a search using the Google Maps API local search with  an iOS MKLocalSearchRequest() ?  For example, using the Google API, making a map search using the keyword "hostels" works correctly. In iOS using MKLocalSearchRequest(), using a naturalLanguageQuery, I just get hotels. Is there a way to fix this?  Or am i forced to use the Google Maps API within iOS?
0
I've been successfully experimenting with interfacing with WordPress's REST API using React.  I've enabled CORS for the remote WordPress site (by modifying it's .htaccess file), and I've succeeded at consuming the JSON data from the API and displaying it by rendering it in my App.js file.  

The code for my App.js file is as follows:

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

import { 
  BrowserRouter,
  Switch, 
  Route
} from 'react-router-dom';

import Home from './components/Home';
import Accounts from './components/Accounts';

class App extends Component {

  constructor() {
    super();
    this.state = {
      accounts: []
    }
  }

componentDidMount() {
  let accountsURL = 'https://mywordpresssite.com/wp-json/wp/v2/posts';
  fetch(accountsURL)
  .then(response => response.json())
  .then(response => {
    this.setState({
      accounts: response
    })
  })
}

  render() {

    let accounts = this.state.accounts.map((account, index) => {

    return (    
        <div key={index}>
          <p>{account.title.rendered}</p>
          <hr/>
        </div>   
      )
    });      

    return (
      <div className="App">

        <header className="App-header">
          <br />
          <img src={logo} className="App-logo" alt="logo" />
        </header>

        <br />     

        {accounts}

        <div className="row">
          <BrowserRouter>
            <Switch>
              <Route path="/" exact 

Open in new window

0
I am trying to show error in Angular 6 but I am using it with query parameters. I am searching for the data using query parameters and if there is any invalid request, I want to show that error. But I am unable to do that. Below is my code

SearchComponent.ts

werbedataSearch(werbenr, produktname, werbetext, artnr, vk_einheit, hinweise) {
    this.router.navigate(['/rullko/werbedata/results/'],
        {
            queryParams:
                {
                    filiale: this.filiale,
                    werbenr: werbenr,
                    artnr: artnr,
                    produktname: produktname,
                    werbetext: werbetext,
                    vk_einheit: vk_einheit,
                    hinweise: hinweise
                }
        });
}

Open in new window

ResultsComponent.ts

ngOnInit(): void {
    this.route.queryParams.subscribe(params => {
      // Defaults to "" if no query param provided.
      this.filiale = params['filiale'] || '';
      this.werbenr = params['werbenr'] || '';
      this.produktname = params['produktname'] || '';
      this.werbetext = params['werbetext'] || '';
      this.artnr = params['artnr'] || '';
      this.vk_einheit = params['vk_einheit'] || '',
        this.hinweise = params['hinweise'] || '',
        this.page = '1' || '';
      this.pageSize = '10' || '';
    });
    this.getPage(1);
  }

Open in new window


service.ts
 getWerbeDataSearch(page: string, pageSize: string, filiale: string, werbenr: string, produktname: string,
    werbetext: string, artnr: string, hinweise: string, vk_einheit: string): Promise<WerbeData[]> {
    const Url = `${this.werbedataSearchUrl}`;
    const params: URLSearchParams = new URLSearchParams();
    params.set('page', page);
    params.set('pageSize', pageSize);
    params.set('filiale', filiale);
    params.set('werbenr', werbenr);
    params.set('produktname', produktname);
    params.set('werbetext', werbetext);
    params.set('artnr', artnr);
    params.set('hinweise', hinweise);
    params.set('vk_einheit', vk_einheit);

    return this.http.get(Url, { search: params, headers: this.headers })
      .toPromise()
      .then(this.extractData)
      .catch(this.handleError);
  }

Open in new window


In service, I am getting error (Requested werbedata does not exist) which i want to show.

Can someone please tell me how to do this?
0
getting api data from posts from another sources to django
hello guys ,

is there any way where

when users can add the link of the post they want to save and the django should add that post allong with description and image to database

eg:

https://www.reddit.com/r/memes/comments/91jdgp/everything_goes_back_to_spongebob/

if i want to save this post

then dango should get data from this post as a json format and should save this post image, description ,title and all to the database

i know this can only be done using api/praw

but cant understand how to make it happen

any kind of help is appreciated
0
Hello Experts,
Just wanted to find out how do you guys dynamically update the Office 365 endpoints IPs and URLs that are published by MS for the proxy and firewall access? I know the RSS feed will be retired soon per what I read online and do you guys just run a PS script that grabs the info from the published XML file or there's a better solution/idea out there? Any input would be greatly appreciated!
0
Hi All,

I'm calling the code below.  

  using (Stream stream = request.GetRequestStream()) throws an error the first time but when I call authenticate again from within the catch it works.  

Postman using the same variables works first time.  I've engaged the hosting company but trying to determine if there's an issue on my side or a reason why it would fail the first time from my code.

Thanks in advanced for the help.



  private static Authenticate Authenticate(bool secondTry=false)
        {
            string url = Config.URL + "token";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.KeepAlive = false;
            request.Headers.Add("Authorization", "Basic " + Utility.Base64Encode(string.Format("{0}:{1}", Config.ConsumerKey, Config.SecretKey)));
            
            request.Method = "POST";

            //what I'm sending to the web request on a post.
            string postData = "grant_type=STUFF";
            
            Byte[] data = Encoding.UTF8.GetBytes(postData);
            request.ContentLength = data.Length;
            
                        
            // default settings.
            request.Accept = "application/json";
            request.ContentType = "application/x-www-form-urlencoded";

          
            AttachClientCert(ref request);  // Attaches PFX to request
            setTLS();  //set TLS to 1.2 and other ServiceManager configs.

            try
            {
    

Open in new window

0
I have a PayPal buy it now client side REST on my website. Payment process is working fine on my end, but the customer, after he pays, doesn't see the payment confirmation screen. I've read on PayPal Dev that I must show a confirmation without redirecting, which is something that I am doing now.


You must show a confirmation without redirecting the page. If you redirect the page, the actions.payment.execute() and actions.payment.get() functions are not available.

This is the code I am using:

payment.asp
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
</head>
<%
Dim price : price = "134.96"
%>
<body>
<div id="paypal-button-container"></div>
</body>
<input type="hidden" name="price" id="price" value="<%=price%>" />
<script src="payment.js"></script>  

Open in new window


payment.js
// JavaScript Document
paypal.Button.render({

env: 'sandbox', // sandbox | production

        style: {
        label: 'checkout',
        size:  'medium',    // small | medium | large | responsive
        shape: 'pill',     // pill | rect
        color: 'silver'      // gold | blue | silver | black
        },

        client: {
            sandbox:    'aaaaaaaaa',
            production: '<insert production client id>'
        },

        // Show the buyer a 'Pay Now' button in the checkout flow
        commit: true,

        // payment() is called when the button is clicked
        payment: function(data, actions) {

            

Open in new window

0
Lets say you have the following REST Service.

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
	xmlns:xe="http://www.ibm.com/xsp/coreex">
	
	(JSON) - View Column - Checkbook
	<xp:br></xp:br>
	<xe:restService id="restService1" pathInfo="GetViewCheckbook">
		<xe:this.service>
			<xe:viewJsonService viewName="VIEWCheckbook" systemColumns="0" defaultColumns="true" compact="true" count="1000"/>
			</xe:viewJsonService>
		</xe:this.service>
	</xe:restService>
</xp:view>

Open in new window


Am I able to access the user name of the logged in user who made the service call?
0
Get your problem seen by more experts
LVL 12
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Is it possible to set different clicks in differten terminal sessions.
We have 1 TS with 30 users. 6 of them are in abudhabi, 2 in malaysia. and the rest in the netherlands.
Is it possible to configure session based clocks in Windows Server 2012 R2?
0
I have created an Xpage custom Rest Service to retrieve a JSON value field from a document.

I take that field value and add other JSON values to a string variable (strJSON).

How can I validate the string variable contains valid JSON?

I receive an error ("'JSON' not found") with the following regardless if the string contains valid JSON:
JSON.parse(strJSON)
0
First and foremost, I am new to xpages.

I have a xpage REST Service that consumes a View Name URL parameter so I can have one service to retrieve any supplied view name.

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
	xmlns:xe="http://www.ibm.com/xsp/coreex">
	
	(JSON) - View Column - Pass View Name
	<xp:br></xp:br>
	<xe:restService id="restService1" pathInfo="GetViewColumns">
		<xe:this.service>
			<xe:viewJsonService systemColumns="0" defaultColumns="true" compact="true" count="1000">
				<xe:this.viewName><![CDATA[#{javascript:param.get("ViewName");}]]></xe:this.viewName>
			</xe:viewJsonService>
		</xe:this.service>
	</xe:restService>
</xp:view>

Open in new window


I receive the following response if the view name provided does not exist:

{
    "code": 400,
    "text": "Bad Request",
    "message": "Unknown view VIEWNAME in database Sample.nsf",
    "type": "text",
    "data": "com.ibm.domino.services.ServiceException: BLAH BLAH BLAH"
}

Open in new window


Can I redesign the service so I can control the error response?

Thanks in advance.
0
MS windows Server NLB services running Cannot ping or telnet mail Server's Virtual IP configured on F5 LTM  neither could telnet on port 25

netstat -ano shows that 10.4.60.182:25 waiting on status Sync_sent (screenshot attached)

Interestingly as soon as i start packet capture on wireshark ping and telnet starts to work

I feel that there is some discrepancy in the  IP or the MAC address  in the communication happenign between f5 and MS windows server (screen shot attached)

As I said MS windows are running NLB services  for web application running, So its NLB VIrtual IP is basically having all the ARP associated to it , screen shot attached

MS server IP 10.4.60.131
MS NLB IP  10.4.60.130

F5 Virtual IP 10.4.60.182
F5 Floating IP  10.4.60.218

Note: MS NLB Can ping and telnet to MS Exchange  CAS IP successfully,  only  failing with F5 however rest of the Servers/ smarthost can commnicate with F5 successfully
0
Hi,
I am working on a POC on KONG api gateway.
Steps followed :
1-  I have installed Kong enterprise edition using docker container. (successful)
2- I ran another spring boot sample docker container
3- configure a service in kong api gateway using admin rest api.
4- configured a route for the service
5- now trying to access the url http://localhost:8000/v1/api/orders, but getting error response "An invalid response was received from the upstream server" with 502 Http error code
When I checked the docker logs file for kong-ee container found the error " 19#0: *10273 connect() failed (111: Connection refused) while connecting to upstream"


Note: Inside Kong-ee container when I tried to access the upstream url using : curl -i -X GET http://127.18.0.1:8082/v1/api/orders it gives me connection refused, but when I tried to
ping 127.18.0.1(which is the ip of docker host machine) it gives me proper reply.
Need some urgent help on this issue.

Any help would be appreciated.
0
Hi All,
I'm working in VB6 (just to set the view).
I'm creating an ActiveX Dll.
I have an OCX which has various events.  The OCX needs to be on a form for it to do anything.
I have a class which isolates the OCX from the rest of the world - all of the OCX properties are supplied by passing through the class
So far, this all works ok.
Where I'm running into problems is trying to get the events from the OCX out of the DLL to be used by the main program.
I have looked and have not been able to find anything.  There are lots of examples showing the WithEvents, but none from a DLL.
Maybe what I want to do isn't possible.
0
One of our clients has exchange 2010 and one user has a huge mailbox (currently about 65GB) so has to work in non-cached mode rather than cached mode.  His OST file just stopped working at 50GB. The user is complaining that searches are not returning all the results it should. Since he is using online mode, I assumed that all the indexing was being done by exchange server and rebuilt the index for the database he was using. (He and one other person share a whole exchange database, the rest of the company is on a different database.) He is still complaining that the search is not returning all the results. I know that when you are in cached mode, the email is indexed by Windows indexing, but what happens in non-cached mode?
0
I am using the following code which sends an email from excel to outlook
Sub Send_Email_Late()

    Dim rng As Range
    Dim OutApp As Object
    Dim OutMail As Object
    Dim Name_Lookup As String
    
  




    

    Set rng = Nothing
    Name_Lookup = ActiveSheet.Range("A3").Value
    
    
    On Error Resume Next
    'Only the visible cells in the selection
    'Set rng = Sheets("Sheet 1").Range("B2:B22").SpecialCells(xlCellTypeVisible)'
    'You can also use a fixed range if you want
    Set rng = Sheets("Stationary").Range("B1:O8").SpecialCells(xlCellTypeVisible)  ':B11
    On Error GoTo 0

    If rng Is Nothing Then
        MsgBox "The selection is not a range or the sheet is protected" & _
               vbNewLine & "please correct and try again.", vbOKOnly
        Exit Sub
    End If

    With Application
        .EnableEvents = False
        .ScreenUpdating = False
    End With

    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
        '.SentOnBehalfOfName = "sales@matthewclark.co.uk"
        .To = ActiveSheet.Range("Cs4").Value
        '.CC = Sheets("Email Data").Range("K2").Value'
        .BCC = ""
        .Subject = "Lateness Email - ENTER DATE"
        .HTMLBody = Name_Lookup & RangetoHTML(rng)
        .Display  'or use .Display
    End With
    On Error GoTo 0

    With Application
        .EnableEvents = True
        .ScreenUpdating = True
    End With
'    MsgBox

Open in new window

0
Hi Experts,
I have the following code which loops thru all records of a given table (on Caspio site) and prints out the contents.
Function GetDataFromCASPIO1()
    Dim objHTTP As New WinHttp.WinHttpRequest
    Dim docXML As MSXML2.DOMDocument
    Dim ResponseText As String
    Dim curNode As IXMLDOMNode
    Dim oNodeList As IXMLDOMSelection

    Set docXML = New MSXML2.DOMDocument

    Set objHTTP = New WinHttp.WinHttpRequest
    URL = "https://abc123.caspio.com/oauth/token"
    
    objHTTP.Open "POST", URL, False
    objHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"

    objHTTP.Send "grant_type=client_credentials&client_id=MyClientID&client_secret=MySecretID"
    ResponseText = Right(objHTTP.ResponseText, Len(objHTTP.ResponseText) - 17)
    access_token = Left(ResponseText, InStr(ResponseText, """") - 1)
    'Debug.Print access_token


    Set objHTTP = New WinHttp.WinHttpRequest
    'objHTTP.setRequestHeader "Content-Type", "application/json"
    URL = "https://abc123.caspio.com/rest/v1/tables/Caregivers/rows"
    objHTTP.Open "GET", URL, False
    objHTTP.SetRequestHeader "Accept", "application/xml"
    objHTTP.SetRequestHeader "Content-Type", "application/json"
    objHTTP.SetRequestHeader "Authorization", "Bearer " + access_token
    objHTTP.Send
    'Debug.Print objHTTP.Status
    'Debug.Print objHTTP.ResponseText
    docXML.loadXML (objHTTP.ResponseText)

    strXPathQuery = "Caspio/Row"
    Set oNodeList = 

Open in new window

0
Cloud Class® Course: Certified Penetration Testing
LVL 12
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

I got a requirement from the business that they want to use single user mailbox for 20 employee but they don't want to use shared mailbox.  now we are facing problem that only 6 outlook profile for the single mailbox are working at the same time and rest are not connecting. if we close any one of them than another outlook profile start working.Hence could anyone please let me know that how many outlook client can be connected for the single mailbox at the same time to the exchange server in exchange 2013 environment.
0
can anyone explain how to create REST API using PHP
0
Hi All,

I'm developing an app that the user can see which of its contacts are registered for the app.
Say I have a data base of users in the cloud what should be the rest end point for such operation?
Should I send all of the user's contact to the endpoint and the server will make the set intersection between the input contact set the its all registered contacts?
But what if the user has many contacts?

Thank u in advance
0
So I have a block of static ip addresses, im currently using one with my peplink router and I have the rest attached to a switch so I can use them for other applications that need public IP's. From within my lan behind the peplink router I cannot get to one of the public ip's I have attached to a device that is sitting on the public ip side of things on that switch.. I can ping it from with in my lan but I cannot access it. My guess there is a port that is being blocked? 443 is the service port and https is turned on. Any tip or trick on what exectly I need to fwd in my peplink router would be greatly appreciated..
0
I currently upload finish line pictures from races I time to Google + and share the gallery with race finishers so they can find their picture.  I would like to take that a step further and share each finishers individual picture with them.  I believe Google Vision has the technology to do that...albeit for a cost...by pairing participant bib number with bib in the image.  Is anyone familiar enough with this api to give me some direction as to how to do this?  Also, any idea how this product is priced?
0
Hi,

I have this json coming from an REST api. I now want to make a representaion of it in my asp.net site (I use vb.net for the moment). But I don't fully get it to work when I create the classes representing the json and deserialize it. This is how the json looks like when I copy it form Postman:
{
    "data": {
        "type": "vehicle",
        "attributes": {
            "regno": "HCA015",
            "vin": "WF0MXXGBWMDP17671"
        },
        "links": [
            {
                "rel": "self",
                "uri": "vehicle/vin/WF0MXXGBWMDP17671"
            },
            {
                "rel": "biluppgifter",
                "uri": "https://biluppgifter.se/fordon/HCA015"
            }
        ],
        "basic": {
            "data": {
                "make": "Ford",
                "model": "GALAXY 2.0 TDCi",
                "status": 2,
                "color": "Svart",
                "type": "PB",
                "vehicle_year": 2013,
                "model_year": 2013
            }
        },
        "inspection": {
            "data": {
                "latest_inspection": "2016-09-19T00:00:00+02:00",
                "inspection_valid_until": "2018-09-30T00:00:00+02:00",
                "meter": 38650,
                "next_inspection_range": [
                    "2018-05-01T00:00:00+02:00",
                    "2018-09-30T00:00:00+02:00"
                ]
            }
        },
        "status": {
            "data": {
                

Open in new window

0

REST

265

Solutions

524

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.

Top Experts In
REST
<
Monthly
>