Request to search bar

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adrianalin
    Member
    • Sep 2017
    • 48

    Request to search bar

    Hello,

    I need to link a barcod scaner to the search bar, for example if i need to link it to google to show the rezults of "sharche term" i wood use https://www.google.com/search?q=sharche+term
    but whit Espo i need to ask somthing like this
    http://localhost/api/v1/Case?maxSize...asc=true&where[0][type]=textFilter&where[0][value]=sharche+term
    and the respons is a json, to not make a json parse php file is ther a whei to acces the rezults of a search term just by accesing a specific adress ?
  • adrianalin
    Member
    • Sep 2017
    • 48

    #2
    And if i cant work like on google wher i acces a link and get a rezult
    help me ajust this pice of cod to get the request to a string theat i can print out

    PHP Code:
    <?php
    
    
    public function putTest() {
        $username    = "admin";
        $password    = "xxxxxxxxx";
        $json_url    = "http://crm.rik.ro/api/v1/Stoc";
        $json_string = "[{"maxSize":"100","offset":"0","sortBy":"grupa","asc":"true","where[0][type]":"textFilter","where[0][value]":"test"}]";
    
        $ch      = curl_init( $json_url );
        $options = array(
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_USERPWD        => "{$username}:{$password}",
            CURLOPT_HTTPHEADER     => array( "Content-type: application/json" ),
            CURLOPT_POSTFIELDS     => $json_string
        );
        curl_setopt_array( $ch, $options );
    
        $result = curl_exec( $ch );
    }
    
    public function getTest() {
        $username    = "admin";
        $password    = "xxxxxxxxx";
        $json_url    = "http://crm.rik.ro/api/v1/Stoc";
    
        $ch      = curl_init( $json_url );
        $options = array(
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_USERPWD        => "{$username}:{$password}",
            CURLOPT_HTTPHEADER     => array( "Accept: application/json" ),
        );
        curl_setopt_array( $ch, $options );
    
        $result = curl_exec( $ch );
    }
    
    
    
    ?>

    Comment

    • tanya
      Senior Member
      • Jun 2014
      • 4308

      #3
      Hi,
      as I imagine it, you need a result with one matching record.
      You can use existing search or you can develop own action for it.
      Hi, I need to know how can I create a new function for api for Example: http://localhost/api/v1/AccountOpening/{id} -&gt; here id by default i need to create


      Maybe I don't understand you.

      Comment

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #4
        Hello, I'm trying to upload contact's document via EspoCRM API v1. The first thing I do is send POST fields to 'api/v1/Attachment'. My POST fields look like this:

        Hi ! Could you please help with the Fatal PHP error on Opportunity creation via API: Espo error_log: [2018-01-25 15:34:44] Espo.WARNING: E_WARNING: Invalid

        Comment

        • adrianalin
          Member
          • Sep 2017
          • 48

          #5
          Yes you imagine it corect.

          I got a barcod scaner and in it's seting i need to put a url, and a %s wher the cod of the barcod wood be replace whit and i wood like when i acces theat url the page to show the matching records in the existing searche. ( and this http://localhost/api/v1/Case?maxSize...asc=true&where[0][type]=textFilter&where[0][value]=sharche+term is only showing my a json respons how can i get the existing searche record only bay acceing a url )

          If this is not posible i need to make a custom php theat i have to acces whit the barcod an theat php wood have to send a request to the api and get the respons procet it and show it ....

          Comment

          • tanya
            Senior Member
            • Jun 2014
            • 4308

            #6
            You can search not by textFilter, but by code field. If the field value is unique, you will get only one record. After this you can redirect espo to this record
            localhost/#Case/{returned_id}

            Comment

            • adrianalin
              Member
              • Sep 2017
              • 48

              #7
              so insted of ....?where[0][type]=textFilter&where[0][value]=5168
              the fild i whant to lookup it's name is "cod" so i sood use .....?where[0][attribute]=cod&where[0][value]=5168&where[0][type]=contains
              but i dont undestend what u ment bay saying "After this you can redirect espo to this record localhost/#Case/{returned_id}"

              Comment

              Working...