Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    jayarami reddy
    Read/pickup the desktop file push to incident of service...Answered
    Topic posted December 22, 2016 by jayarami reddyRed Ribbon: 250+ Points 
    670 Views, 22 Comments
    Title:
    Read/pickup the desktop file push to incident of service cloud
    Content:

    Hi,

    I am trying Read/pickup the desktop file push to incident of service cloud using Connect PHP API.

    but  i am getting  empty result and am using the below code

    please help me this issue

    Version:
    Service Cloud
    Code Snippet:

    Best Comment

    Pramod Vasudeva Murthy

    Jayarami,

    If you want to automate this process, place a file in a shared location and use web service calls to create/update records. I do not think any CRM(at-least I know) will have ability to pick a file in YOUR DESKTOP and import automatically.

    p.s: I don't see the reason on extending post anymore after all said and done. Please share your tryouts, we can guide you accordingly.

    - VIP

    Comment

    • Scott Harwell

      It appears that you might be confused about how a server side script operates.  The script that you have written attempts to pickup JRRTEST.txt from the same directory that PHP is running on the server.  This, of course, will not have your file since you mentioned that it's on your desktop.  In order for PHP to read the file, it would already have to exist in an accessible folder on the server.

      You shouldn't be running imports from text files through a custom process model in any case.  If you want to import a file from your "desktop" or local PC, write the script so that it runs locally and uses the SOAP or REST API to post the data to the OSVC.

      Also, you're writing logs to the assets folder, which is exposed on the public internet and likely means that you're opening up a security hole for intruders to see what your script does and how to compromise it.  You should not do that.

      What is the purpose of the script and when should it be triggered?  Likely, there is a much better approach to do what you are attempting.

    • jayarami reddy

      HI Scott Harwell,

      Thanks for the reply.

      Here I'm trying to achieve is a .csv file is in local Folder/Desktop that respective .csv file should read by PHP code and send to service cloud(OSVC). Above code is what I'm trying to do but not able to do it.

      Can you suggest me on reading the .csv file from Desktop and send to OSVC.

      Regards,

      jayram

    • Barrilito van Dijk

      Hi jayram,

      What Scott is trying to say is that you are making a lot of combinations of things that won't work together.

      We understand more or less from your code what you are technically trying to do, but I think that what Scott means is that we want to know what the purpose is behind the code you are trying to write. What kind of data is in your txt/csv file, what data do you want to get into service cloud. Where should the data be stored, what do you expect the system to do with the data. Etc, etc.

      OSC has a build in data import wizzard, do you know about it?  You can find some information here.

      Regards.

    • Pramod Vasudeva Murthy

      Jayarami,

      PHP is a server side script, that means moment you see a '.php' it is always executed by server except for any JS which is executed by browser.

      You cannot expect a csv file stored in your local machine to pick up by php and do a CRUD operation. It is simply not possible and for fact none of the CRM's work like that.

      Either manually upload CSV or Batch pgm(where this CSV placed in a Server location and uses CWSS) - these are the ways that I could think of that are near to scheduling a auto-import.

      Apart from this you can do other way around - For instance if you are synching data from Oracle Sales to Service - try exploring similar options in Sales cloud.

      - VIP

    • jayarami reddy

      Hi Pramod,

      Do we have content server in service cloud?

      Content server in sales cloud is a place where we store our CSV files and pick files from there.

       

      Thanks,

      Jayarami.

    • Scott Harwell

      @pramod You certainly could run a PHP script locally on your machine and have it perform operations against a remote API. While PHP is typically used for server-side scripting, there's nothing from preventing you from writing a PHP script that runs locally on your PC, leverages the filesystem, and sends the data to OSvC or any other CRM via web services.  That said, Jayarami appears to be attemping to pull a local file from a server side script, which is where the discrepancy is.  And, if running locally, you don't have access to ConnectPHP libraries; you have to use web services to communicate to OSvC.

      @jayarami There are places where you could store CSV files and import them.  However, there are no places where you really should do that.  Assets would be publicly exposed, folders through file manager limit your automation, and the goal of the web services is to move batch processes to use those managed APIs.  You can write a server-side hosted PHP script that imports data from these folders, but it comes with compromises that are usually not worth that approach in the long term.

      I would recommend creating a process within your organization (it can be any technology that can read your file and call web services) that does just that.  You could setup a cron to push and pull data as needed and you would control both the timing of when the script runs and the data passed to and from the API(s).  You could even used hosted or PaaS services that are very inexpensive to run the process in the cloud too.

    • Danette Beal

      Hi Jayarami,

      I wanted to chime in on this post and ask you to please consider Scott's recommendations for how to handle customer data. I would encourage you test your development carefully and ensure there is no exposures in whatever route you take. I would hate to inadvertently cause exposure and it appears there could be some risk here.

      Regards,

      Danette, Community Manager

       

    • jayarami reddy

      Hi Scott,

      Read the desktop file using web service is possible? if any possible ways there please give the more information.

       

    • jayarami reddy

      Hi Scott,

      you said  ''it can be any technology that can read your file and call web services'', which web services we have use in service cloud.

      please help me this issue

       

       

       

    • Danette Beal

      Hi Jayarami,

      Sounds like you are going down the route of creating a process within your organization as Scott mentioned. It may be helpful to know what potential solutions you have come up with around this avenue. Is this possible within the Org you are working with? A little more information around your ask could lead to better understanding of Scott and team to lead you down the right path.

      Thanks again!

      Danette, Community Manager

       

    • Scott Harwell

      Thanks for following up, Danette.

      @jayarami, you can find documentation for both SOAP and REST web services through the links at the top of this site.  Here's a link.  Using SOAP or REST APIs with PHP on your local machine, you can loop through your data files and then push the data to OSvC.  If you're unaware how to do that, I would suggest contacting an Oracle Service Cloud Systems Integrator to help you with your implementation as you need experience with the programming language, integrating with web services, and any technology that might be required to schedule/configure a reoccuring process that you seem to need.

    • Dietrik

      @jayarami : Maybe you should be more clear on your use case, and design a solution using the possibilities available, both in OSC and in your own infrastructure.

      As it looks now, you're probably getting too many suggestions, valid as they might be, to be of much help to you.

    • Rajan Davis

      This probably going to be a very strange post, but here's how you can do it with Ruby and the Connect REST API; I highlighted the portions that you would need to swap out:

      require "json"
      require "net/http"
      require "uri"
      require "openssl"
      require "base64"
      
      # put the path to the file you wish to upload
      @file_path = "path/to/file"
      
      # instantiates a Ruby file object
      @file = File.new(@file_path)
      
      # gets the file name from the file
      @file_name = File.basename(@file)
      
      # generates Base64 encoded version of the file
      @data = Base64.encode64(File.open(@file_path, "rb").read)
      
      # sets the interface to where you wish to create the incident
      @interface = ENV['OSC_TEST_SITE'] # => 'test-site'
      
      # create an empty hash
      @json_content = {}
      
      # assign a hash to the 'primaryContact' key
      @json_content['primaryContact'] = {}
      
      # set the value of the primary contact ID for the incident
      @json_content['primaryContact']['id'] = 236948
      
      # set the value for the subject line of the incident
      @json_content['subject'] = 'Test please delete'
      
      # create an empty array for the file attachment data
      @json_content['fileAttachments'] = []
      
      # input the file attachment data as a hash into the empty array
      @json_content['fileAttachments'][0] = {'fileName' => @file_name, 'data' => @data}
      
      # parse the URL for the REST API endpoint
      @uri = URI.parse("https://#{@interface}.custhelp.com/services/rest/connect/v1.3/incidents")
      
      # input your Oracle Service Cloud credentials here
      @username = ENV['OSC_ADMIN'] # => 'username'
      @password = ENV['OSC_PASSWORD'] # =>  'password'
      
      # sets a variable for the Net::HTTP response for post the incident and fileattachment information above
      response = Net::HTTP.start(@uri.host, @uri.port,
              :use_ssl => true, 
              :verify_mode => OpenSSL::SSL::VERIFY_PEER) do |http|
      
              request = Net::HTTP::Post.new @uri.request_uri
              request.basic_auth @username, @password
              request.content_type = "application/json"
              request.body = JSON.dump(@json_content)
      
              http.request request # Net::HTTPResponse object
      
      end
      
      # will tell you the HTTP response code
      puts response.code
      
      # will tell you the JSON output from the REST API
      puts response.body
      

      I tested this with Ruby 2.1.2p95 on Mac OSX and with Oracle Service Cloud November 2016 (Build 272) SP1. Not sure if it will work on your current version, but I was able to see the file attachments in the incident workspace in the agent console.

    • Barrilito van Dijk

      @Rajan: This is indeed getting a strange post wink I do like it that so many people (like yourself) come up with so many things and even give away full code samples. I appreciate that a lot, it realy is a compliment to all of you! However, I still don't see the actual usecase being explained here.  Reading a file is not a usecase. What is in the file, what do you what to do with the data, etc... Like Dietrik said, so many help but perhaps we should be clear about a usecase first.

      Regards

    • jayarami reddy

      @Rajan: my exact requirement is on system desktop one file there i want pickup the file data and i want do mapping the file data and incident fields and directly update the incident.

      any possible ways there ?

      please help me this issue.