0

I am trying to add / update a test record in a data extension from a cloud page but I keep getting 500 - Internal server error

I have looked at the online resources and some answers here as well before creating this question but I can't seem to understand where is the issue in my code?

Here is my cloud page (landing page) code:

%%[

Set @subkey = "[email protected]"
  

SET @deRequest = CreateObject("DataExtensionObject")
SetObjectProperty(@deRequest, "CustomerKey","12345-1234-1234-1234-12345678")
 
     
SET @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
SetObjectProperty(@lue_prop, "Value", @subkey)
AddObjectArrayItem(@deRequest , "Key", @lue_prop)
   

SET @updateOptions = CreateObject("UpdateOptions")
SET @saveOptions = CreateObject("SaveOption")
SetObjectProperty(@saveOptions, "PropertyName", "DataExtensionObject")
SetObjectProperty(@saveOptions, "SaveAction", "UpdateAdd")
AddObjectArrayItem(@updateOptions, "SaveOptions", @saveOptions)

SET @ts_statusCode = InvokeUpdate(@deRequest, @de_statusMsg, @errorCode, @updateOptions)

IF @ts_statusCode != "OK" THEN
    RaiseError(@de_statusMsg, 0, @de_statusCode, @errorCode)
ENDIF
    
    ]%%

<html>
    <head>
    </head>
    <body style="font-family:sans-serif;">
      <br/>@subkey: %%=v(@subkey)=%%
      <br/>@ts_statusCode: %%=v(@ts_statusCode)=%%
    </body>
</html>

ERROR: Server Error 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed.

4
  • 1
    Why are you not using the upsertData function? It is a single line of code, doing what you are looking for: ampscript.guide/upsertdata Commented Sep 13, 2023 at 4:46
  • Hi @LukasLunow my understanding is that using the API property approach, the solution will be optimized and can handle a ton of traffic where multiple updates to the DE may occur from different customers at the exact same time; while upsertData function may be a better option for a low traffic page or batch processes. Is that correct understanding or am I missing anything? Please advise
    – kl2
    Commented Sep 13, 2023 at 10:56
  • I am not aware of this difference, can you share your source? But again, how many submissions per second are you counting on? As this will be something done on a CloudPage, I will not expect a lot of concurrent requests, hence UpsertData should be sufficient. Commented Sep 13, 2023 at 11:01
  • Thanks @LukasLunow for your prompt response. While I look for the source, do you have any advise on thie approach posted in my question (why it is throwing an error)? I'm still curious to learn why I'm failing to update a DE in this case? I have followed this solution source
    – kl2
    Commented Sep 13, 2023 at 11:08

0

You must log in to answer this question.

Browse other questions tagged .