This topic contains 3 replies, has 2 voices, and was last updated by hungpv.dev 7 years, 10 months ago.
- Topic
Hi,
I ‘m unable to search email with special characters through advanced search api
Query:1tpl-crm.local/api/rest/latest/search/advanced?query=from orocrm_contact where email ~ "hungpv.dev@gmail.com"This query return only one contact.
But some email like this
1tpl-crm.local/api/rest/latest/search/advanced?query=from orocrm_contact where email ~ "hungpv.dev+100@gmail.com"return not exactly email i want. (There is only one contact use this email)
Screenshot use Postman
I tried to run this code in laravel.
I tried to use url encode $email only, $query, $endpoint. The result always is 404 not found.12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849public function searchByEmail($bundle, $email){$method = 'GET';$query = '?query=from ' . $bundle . ' where email ~ ' . $email;$endpoint = '/api/rest/latest/search/advanced' . $query;$endpoint = urlencode($endpoint);$data = $this->_createOroRequest($method, $endpoint);return $data;}protected function _createOroRequest($method, $endpoint, $data = []){$userName = isset($this->_orocrmconfig['username']) ? $this->_orocrmconfig['username'] : '';$userPassword = isset($this->_orocrmconfig['api_key']) ? $this->_orocrmconfig['api_key'] : '';$baseUri = isset($this->_orocrmconfig['base_uri']) ? $this->_orocrmconfig['base_uri'] : '';if (!$userName || !$userPassword || !$baseUri) {throw new \Exception('Invalid CRM information!');}$nonce = uniqid();$created = date('c');$digest = base64_encode(sha1(base64_decode($nonce) . $created . $userPassword, true));$wsseHeader = ['Accept' => 'application/json','Authorization' => 'WSSE profile="UsernameToken"','X-WSSE' => sprintf('UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"',$userName,$digest,$nonce,$created)];$client = new Client(['headers' => $wsseHeader,'base_uri' => $baseUri,'verify' => false]);$response = $client->request($method, $endpoint, ['form_params' => $data]);$response = (string)$response->getBody();return json_decode($response, true);}Question:
How to convert email to some form that is search more accurately?
There is anything i need to change my php code to make this function work like postman?
The forum ‘OroPlatform’ is closed to new topics and replies.