Adding bodycopy content via SOAP API


(Mahearnpad) #1

Hello


I've looked through the list of available methods for creating assets and cannot find anything that will allow me to add html content to a standard page via the SOAP API.



But just in case, I need to ask. Is this possible?? Has anyone out there done this? Nick?



TIA

Michael


(Nic Hubbard) #2

No, I have not done this, but here is an untested idea:


Create your Standard Page asset and when SOAP returns the created id, use that with the GetChildren function to get the children of your new asset. That should include the newly created bodycopy and bodycopy div. Then, you might be able to set the content on one of those assets.



It is just an idea, and I have no idea if it will work.


(Mahearnpad) #3

Thanks Nick
You're on the money with the methods to create and get the children of the created asset. I can do this, but there doesn't seem to be a way to set the content of these assets, unless I'm missing something obvious.




[quote]

No, I have not done this, but here is an untested idea:



Create your Standard Page asset and when SOAP returns the created id, use that with the GetChildren function to get the children of your new asset. That should include the newly created bodycopy and bodycopy div. Then, you might be able to set the content on one of those assets.



It is just an idea, and I have no idea if it will work.

[/quote]


(Benjamin Pearson) #4

[quote]
Hello



I've looked through the list of available methods for creating assets and cannot find anything that will allow me to add html content to a standard page via the SOAP API.



But just in case, I need to ask. Is this possible?? Has anyone out there done this? Nick?



TIA

Michael

[/quote]



Assuming it is a basic standard page:

  1. Use GetChildren() and look for Content Type wysiwyg underneath that page to get the Asset ID of that content type.
  2. Use SetAttributeValue() with the Asset ID of the content type and the Attribute name is 'html'.



    HTH

(Mahearnpad) #5

[quote]
Assuming it is a basic standard page:

  1. Use GetChildren() and look for Content Type wysiwyg underneath that page to get the Asset ID of that content type.
  2. Use SetAttributeValue() with the Asset ID of the content type and the Attribute name is 'html'.



    HTH

    [/quote]



    Thanks. OK, this gives me a raw html div on the bodycopy. Still need to add the html content to it. Methinks this is not possible. ??



    M

(Nic Hubbard) #6

[quote]
Thanks. OK, this gives me a raw html div on the bodycopy. Still need to add the html content to it. Methinks this is not possible. ??



M

[/quote]



And you tried using SetAttributeValue() and it didn't work? What was the error?


(Mahearnpad) #7

[quote]
And you tried using SetAttributeValue() and it didn't work? What was the error?

[/quote]





Here's the error I get on SetAttributeValue():



[PHP Fatal error: Uncaught exception 'Exception' with message 'SOAP fault encountered on attribute value change: Attribute "html" not found for Asset of type "bodycopy_div" [SYS0093]' in /home/nps/public_html/HealthLinks_webservices/ChangeAttribute.php:46

Stack trace:

#0 {main}

thrown in /home/nps/public_html/HealthLinks_webservices/ChangeAttribute.php on line 46]



Seems that "html" is not the correct attribute name. I don't know where to find the list of attribute names. Our CMS is hosted by Squiz, so I don't have access to all the php scripts or db tables :frowning:


(Squiz) #8

[quote]
Seems that "html" is not the correct attribute name. I don't know where to find the list of attribute names. Our CMS is hosted by Squiz, so I don't have access to all the php scripts or db tables :frowning:

[/quote]



I just had a peek in my system, it looks like there could be another "content type" asset inside the "bodycopy div" which has the "html" attribute. In my case I've got:


    Standard Page -> Bodycopy Div -> WYSIWYG Content Type


According to our database here, the "content_type" and "content_type_wysiwyg" assets are the ones that have the "html" attribute. So I'd see if you can find any further children, and try SetAttributeValue on that.

(Mahearnpad) #9

[quote]
I just had a peek in my system, it looks like there could be another "content type" asset inside the "bodycopy div" which has the "html" attribute. In my case I've got:


    Standard Page -> Bodycopy Div -> WYSIWYG Content Type


According to our database here, the "content_type" and "content_type_wysiwyg" assets are the ones that have the "html" attribute. So I'd see if you can find any further children, and try SetAttributeValue on that.
[/quote]


Yes! That works!

Thanks

(Chris Horikx) #10

Assuming it is a basic standard page: 1. Use GetChildren() and look for Content Type wysiwyg underneath that page to get the Asset ID of that content type.
2. Use SetAttributeValue() with the Asset ID of the content type and the Attribute name is 'html'.

HTH

Thanks Ben, this worked for me