Advertisement
Guest User

Untitled

a guest
Apr 30th, 2018
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var atype = 'digital'
  2.  
  3. var activity_uuid = 'a039z8f9-24e5-495c-a894-a044c767c49a'
  4.  
  5. var body2 = {
  6.   "data": {
  7.     "type": "my_activity--"+atype,
  8.     "id": activity_uuid,
  9.     "attributes": {
  10.       'id': 18,
  11.       'uuid': activity_uuid,
  12.       'notes': 'some debug text if you have a notes field'
  13.     },
  14.     "relationships": {
  15.       "type": {
  16.         "data": {
  17.           "type": "my_activity_type--my_activity_type",
  18.           "id": "109e0f74-1995-4836-a044-7fc40f05b39c"
  19.         },
  20.         "links": {
  21.           "self": "http://me.net/my_activity/digital/"+activity_uuid+"/relationships/type",
  22.           "related": "http://me.net/my_activity/digital/"+activity_uuid+"/type"
  23.         }
  24.       },
  25.       "products": {
  26.         "data": [
  27.           {
  28.             "type": "paragraph--products",
  29.             "id": "42c0aba4-0e5c-411d-99e0-63305b66c1ef",
  30.             "meta": {
  31.               "target_revision_id": "11" // A revision of this product.
  32.             }
  33.           },
  34.           {
  35.             "type": "paragraph--products",
  36.             "id": "3da8f866-346e-4386-acc5-18040949828e",
  37.             "meta": {
  38.               "target_revision_id": "13"
  39.             }
  40.           }
  41.         ],
  42.         "links": {
  43.           "self": "http://me.net/my_activity/digital/"+activity_uuid+"/relationships/products",
  44.           "related": "http://me.net/my_activity/digital/"+activity_uuid+"/products"
  45.         }
  46.       }
  47.     }
  48.  
  49.   }
  50. }
  51.  
  52. try {
  53.  
  54.   init = {
  55.     method: 'PATCH',
  56.     headers: {
  57.       'Authorization': 'Bearer '+auth.access_token,
  58.       'Content-Type': 'application/vnd.api+json',
  59.     },
  60.     body: JSON.stringify(body2),
  61.   };
  62.   // Some fetch implementation.
  63.   _fetch(this, '/my_activity/'+atype+'/'+activity_uuid, init)
  64.  
  65. } catch(error) {
  66.   // Something.
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement