function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sk2006sk2006 

perl creating attachment

I am trying to  create an attachment using perl and the API. I am base64 encoding the string using MIME::Base64's encode_base64 method. Here's my create call:

        my $r = $sf->create( type=>'Attachment',
                    Body => "$filedata",
                    Name => "$uploaded_filename",
                    ParentId => "$caseid"
                    );

Here's what I get back:

$VAR1 = { 'success' => 'false', 'errors' => { 'fields' => undef, 'statusCode' => 'INVALID_TYPE_ON_FIELD_IN_RECORD', 'message' => 'Body: value not of required type: VGhpcyBpcyBhIHRlc3QgZm9yIHRoZSBhdHRhY2htZW50IGZlYXR1cmUuIE5vdCBjb21wcmVzc2lu ZyBiZWZvcmUgaW5zZXJ0IHlldC4=' }, 'id' => undef };

Can someone help please?
SuperfellSuperfell
Its likely that your request is claiming body is an xsd:string, when in fact its xsd:base64Binary. However I'm not sure how you tell perl to send the different type
sk2006sk2006
Thank you. Armed with this hint and some previous info you guys have provided, I was able to do this to accomplish what I wanted.

    $Salesforce::Constants::TYPES{Attachment}->{Body} = 'xsd:base64Binary';
baysidebayside
Many constants was added in WWW::Salesforce::Constants::TYPES
at WWW::Salesforce version 0.07.

You can download WWW::Salesforce version 0.07 from
http://search.cpan.org/~capoeirab/WWW-Salesforce-0.07/
Please try it!

iti-commsiti-comms
bayside++

I couldn't have said it better myself.

- Chase (capoeirab)