Options

cURL not returning results in Execute Process

rachel_lomaskyrachel_lomasky Member Posts: 52 Guru
edited November 2018 in Help

When I run the following code on the command line:

curl -X POST -H Content-Type:application/json -H Accept:application/json http://api.intellexer.com/analyzeSentiments?apikey=a91714aa-4db7-4264-8ab9-f209f592a0b3 -d '[{"id":"1","text":"neurotic"},{"id":"2","text":"tiny"},{"id":"3","text":"sensibility"}]'

I get the response:

{"sentimentsCount":3,"ontology":null,"sentences":[{"sid":"1","text":"<neg w=\"-1.65\">neurotic<\/neg>","w":-2},{"sid":"2","text":"<neg w=\"-1.65\">tiny<\/neg>","w":-2},{"sid":"3","text":"sensibility","w":0}],"opinions":null,"sentiments":[{"author":null,"dt":null,"id":"1","title":null,"w":-2},{"author":null,"dt":null,"id":"2","title":null,"w":-2},{"author":null,"dt":null,"id":"3","title":null,"w":0}]}

However, when I run it through an Execute Process, the document it returns is size 0.

 

 

I know that the header parameters need to be unquoted in this case, but I'm wondering what else I need to do to retrieve a response.

 

Here's my process:

<?xml version="1.0" encoding="UTF-8"?><process version="7.4.000">
<operator activated="true" class="productivity:execute_program" compatibility="7.4.000" expanded="true" height="103" name="cURL for sentiment (2)" width="90" x="45" y="34">
<parameter key="command" value="curl -X POST -H Content-Type:application/json -H Accept:application/json http://api.intellexer.com/analyzeSentiments?apikey=a91714aa-4db7-4264-8ab9-f209f592a0b3 -d '[{&quot;id&quot;:&quot;1&quot;,&quot;text&quot;:&quot;neurotic&quot;},{&quot;id&quot;:&quot;2&quot;,&quot;text&quot;:&quot;tiny&quot;},{&quot;id&quot;:&quot;3&quot;,&quot;text&quot;:&quot;sensibility&quot;}]'"/>
<parameter key="log_stdout" value="true"/>
<parameter key="log_stderr" value="true"/>
<list key="env_variables"/>
</operator>
</process>
<?xml version="1.0" encoding="UTF-8"?><process version="7.4.000">
<operator activated="true" class="text:read_document" compatibility="7.2.001" expanded="true" height="68" name="to document (18)" width="90" x="179" y="34">
<parameter key="extract_text_only" value="true"/>
<parameter key="use_file_extension_as_type" value="true"/>
<parameter key="content_type" value="txt"/>
<parameter key="encoding" value="SYSTEM"/>
<description align="center" color="transparent" colored="false" width="126">surveys to document</description>
</operator>
</process>
<?xml version="1.0" encoding="UTF-8"?><process version="7.4.000">
<operator activated="true" class="text:json_to_data" compatibility="7.2.001" expanded="true" height="82" name="JSON To Data (19)" width="90" x="313" y="34">
<parameter key="ignore_arrays" value="false"/>
<parameter key="limit_attributes" value="false"/>
<parameter key="skip_invalid_documents" value="false"/>
</operator>
</process>

P.S. The token is a free trial one, so no worries as far as giving that away.

Answers

  • Options
    Edin_KlapicEdin_Klapic Moderator, Employee, RMResearcher, Member Posts: 299 RM Data Scientist

    Dear Rachel,

     

    We tried to reproduce your problem and also received somewhat strange results. What we did find out is that this highly depends on the OS where you execute the command. Execute Program is definitely able to execute the cURL command and delivers results with simpler options.

     

    In order to be more platform independent (OS X vs. Unix vs. Windows) we recommend the operator Enrich Data by Webservice which is used in the attached example process.

     

    Best,

    Edin

     

    <?xml version="1.0" encoding="UTF-8"?><process version="7.4.000">
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="7.4.000" expanded="true" name="Process">
    <process expanded="true">
    <operator activated="true" class="generate_data_user_specification" compatibility="7.4.000" expanded="true" height="68" name="Generate Data by User Specification" width="90" x="112" y="34">
    <list key="attribute_values"/>
    <list key="set_additional_roles"/>
    </operator>
    <operator activated="true" class="web:enrich_data_by_webservice" compatibility="7.3.000" expanded="true" height="68" name="Enrich Data by Webservice (2)" width="90" x="246" y="34">
    <parameter key="query_type" value="Regular Expression"/>
    <list key="string_machting_queries"/>
    <list key="regular_expression_queries">
    <parameter key="test" value="(.*)"/>
    </list>
    <list key="regular_region_queries"/>
    <list key="xpath_queries"/>
    <list key="namespaces"/>
    <list key="index_queries"/>
    <list key="jsonpath_queries"/>
    <parameter key="request_method" value="POST"/>
    <parameter key="body" value="[{&quot;id&quot;:&quot;1&quot;,&quot;text&quot;:&quot;neurotic&quot;},{&quot;id&quot;:&quot;2&quot;,&quot;text&quot;:&quot;tiny&quot;},{&quot;id&quot;:&quot;3&quot;,&quot;text&quot;:&quot;sensibility&quot;}]"/>
    <parameter key="url" value="http://api.intellexer.com/analyzeSentiments?apikey=a91714aa-4db7-4264-8ab9-f209f592a0b3"/>
    <list key="request_properties">
    <parameter key="Content-Type" value="application/json"/>
    <parameter key="Accept" value="application/json"/>
    </list>
    </operator>
    <connect from_op="Generate Data by User Specification" from_port="output" to_op="Enrich Data by Webservice (2)" to_port="Example Set"/>
    <connect from_op="Enrich Data by Webservice (2)" from_port="ExampleSet" to_port="result 1"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    </process>
    </operator>
    </process>
Sign In or Register to comment.