Skip to content

Post API Add Post Example Video File MP4

Dominik Magdaleński edited this page Jul 3, 2019 · 1 revision

Post API - /add_post - Video File (MP4) template example

  1. Add MediaUploadRequest:

    Request:

    http --follow POST https://dive-networks.com/api/rpc/34/add_media_upload_request \
    Authorization:"Token your-api-token-here" \
    media_type=video
    

    Response:

    HTTP/1.1 201 Created
    (...headers...)
    
    {
        "result": {
            "created_at": "2019-06-26T05:01:35.630909-04:00", 
            "data": {}, 
            "expires_at": "2019-06-26T05:11:35.171744-04:00", 
            "id": 35, 
            "media_type": "video", 
            "presigned_s3_post": {
                "fields": {
                    "key": "videos/fb1af103-e5a7-4b76-b3ef-e69d31c9ab2b", 
                    "policy": "eyJleHBpcmF0aW9uIjogIjIwMTktMDYtMjZUMDk6MTE6MzVaIiwgImNvbmRpdGlvbnMiOiBbWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsIDAsIDEwNzM3NDE4MjRdLCB7ImJ1Y2tldCI6ICJkaXZlLW1lZGlhLXVwbG9hZC10ZXN0LTIyMDQyMDE5In0sIHsia2V5IjogInZpZGVvcy9mYjFhZjEwMy1lNWE3LTRiNzYtYjNlZi1lNjlkMzFjOWFiMmIifSwgeyJ4LWFtei1hbGdvcml0aG0iOiAiQVdTNC1ITUFDLVNIQTI1NiJ9LCB7IngtYW16LWNyZWRlbnRpYWwiOiAiQUtJQVhMN0VBR0RRUUdFSFdRUUkvMjAxOTA2MjYvZXUtY2VudHJhbC0xL3MzL2F3czRfcmVxdWVzdCJ9LCB7IngtYW16LWRhdGUiOiAiMjAxOTA2MjZUMDkwMTM1WiJ9XX0=", 
                    "x-amz-algorithm": "AWS4-HMAC-SHA256", 
                    "x-amz-credential": "AKIAXL7EAGDQQGEHWQQI/20190626/eu-central-1/s3/aws4_request", 
                    "x-amz-date": "20190626T090135Z", 
                    "x-amz-signature": "34b3bf51ca5e45014336ce8e9b86877519ad10054f4cb13e73d52a4f201db71a"
                }, 
                "url": "https://dive-media-upload-test-22042019.s3.amazonaws.com/"
            }, 
            "status": "init", 
            "updated_at": "2019-06-26T05:01:35.630946-04:00"
        }
    }
    
  2. Upload video (copy URL and form field values from the MediaUploadRequest):

    Request:

    http --follow --form POST https://dive-media-upload-test-22042019.s3.amazonaws.com/ \
    key="videos/fb1af103-e5a7-4b76-b3ef-e69d31c9ab2b" \
    policy="eyJleHBpcmF0aW9uIjogIjIwMTktMDYtMjZUMDk6MTE6MzVaIiwgImNvbmRpdGlvbnMiOiBbWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsIDAsIDEwNzM3NDE4MjRdLCB7ImJ1Y2tldCI6ICJkaXZlLW1lZGlhLXVwbG9hZC10ZXN0LTIyMDQyMDE5In0sIHsia2V5IjogInZpZGVvcy9mYjFhZjEwMy1lNWE3LTRiNzYtYjNlZi1lNjlkMzFjOWFiMmIifSwgeyJ4LWFtei1hbGdvcml0aG0iOiAiQVdTNC1ITUFDLVNIQTI1NiJ9LCB7IngtYW16LWNyZWRlbnRpYWwiOiAiQUtJQVhMN0VBR0RRUUdFSFdRUUkvMjAxOTA2MjYvZXUtY2VudHJhbC0xL3MzL2F3czRfcmVxdWVzdCJ9LCB7IngtYW16LWRhdGUiOiAiMjAxOTA2MjZUMDkwMTM1WiJ9XX0=" \
    x-amz-algorithm="AWS4-HMAC-SHA256" \
    x-amz-credential="AKIAXL7EAGDQQGEHWQQI/20190626/eu-central-1/s3/aws4_request" \
    x-amz-date="20190626T090135Z" \
    x-amz-signature="34b3bf51ca5e45014336ce8e9b86877519ad10054f4cb13e73d52a4f201db71a" \
    file@~/Videos/sample.mp4
    

    Response:

    HTTP/1.1 204 No Content
    (...headers...)
    
  3. Get "data" from the MediaUploadRequest (it should be ready after a short while):

    Request:

    http --follow https://dive-networks.com/api/rpc/34/get_media_upload_request?id=35 \
    Authorization:"Token your-api-token-here"
    

    Response:

    HTTP/1.1 200 OK
    (...headers...)
    
    {
        "result": {
            "created_at": "2019-06-26T05:01:35.630909-04:00", 
            "data": {
                "uploaded_file_s3_bucket": "dive-cms-media", 
                "uploaded_file_s3_key": "s/v/81hoxBB9ScmOJh14i7sQ_fb1af103-e5a7-4b76-b3ef-e69d31c9ab2b.mp4", 
                "uploaded_file_size_bytes": 1055736, 
                "video_filename": "fb1af103-e5a7-4b76-b3ef-e69d31c9ab2b.mp4", 
                "video_url": "https://cdn.filestackcontent.com/4t8t8NPQTruDXKG4YqPH"
            }, 
            "expires_at": "2019-06-26T05:11:35.171744-04:00", 
            "id": 35, 
            "media_type": "video", 
            "presigned_s3_post": {
                "fields": {
                    "key": "videos/fb1af103-e5a7-4b76-b3ef-e69d31c9ab2b", 
                    "policy": "eyJleHBpcmF0aW9uIjogIjIwMTktMDYtMjZUMDk6MTI6MzJaIiwgImNvbmRpdGlvbnMiOiBbWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsIDAsIDEwNzM3NDE4MjRdLCB7ImJ1Y2tldCI6ICJkaXZlLW1lZGlhLXVwbG9hZC10ZXN0LTIyMDQyMDE5In0sIHsia2V5IjogInZpZGVvcy9mYjFhZjEwMy1lNWE3LTRiNzYtYjNlZi1lNjlkMzFjOWFiMmIifSwgeyJ4LWFtei1hbGdvcml0aG0iOiAiQVdTNC1ITUFDLVNIQTI1NiJ9LCB7IngtYW16LWNyZWRlbnRpYWwiOiAiQUtJQVhMN0VBR0RRUUdFSFdRUUkvMjAxOTA2MjYvZXUtY2VudHJhbC0xL3MzL2F3czRfcmVxdWVzdCJ9LCB7IngtYW16LWRhdGUiOiAiMjAxOTA2MjZUMDkwMjMyWiJ9XX0=", 
                    "x-amz-algorithm": "AWS4-HMAC-SHA256", 
                    "x-amz-credential": "AKIAXL7EAGDQQGEHWQQI/20190626/eu-central-1/s3/aws4_request", 
                    "x-amz-date": "20190626T090232Z", 
                    "x-amz-signature": "835cd7d544e8069d2def2f5ff5f1073c530ca4bd30933fc4b51b3c0c0150a90c"
                }, 
                "url": "https://dive-media-upload-test-22042019.s3.amazonaws.com/"
            }, 
            "status": "succeeded", 
            "updated_at": "2019-06-26T05:02:32.836717-04:00"
        }
    }
    
  4. Add Post:

    body.json:

    {
      "template": "video-upload",
      "title": "Big Buck Bunny!",
      "content_zones": [
        15
      ],
      "uploaded_file_s3_bucket": "dive-cms-media",
      "uploaded_file_s3_key": "s/v/81hoxBB9ScmOJh14i7sQ_fb1af103-e5a7-4b76-b3ef-e69d31c9ab2b.mp4",
      "uploaded_file_size_bytes": 1055736,
      "video_filename": "fb1af103-e5a7-4b76-b3ef-e69d31c9ab2b.mp4",
      "video_url": "https://cdn.filestackcontent.com/4t8t8NPQTruDXKG4YqPH"
    }
    

    Request:

    http --follow POST https://dive-networks.com/api/rpc/34/add_post \
    Authorization:"Token your-api-token-here" \
    < body.json
    

    Response:

    HTTP/1.1 201 Created
    (...headers...)
    
    {
        "result": {
            "background_color": "ffffff", 
            "body": null, 
            "content_zones": [
                15
            ], 
            "duration": null, 
            "frequency": 300, 
            "fullscreen_playback": false, 
            "id": 13365, 
            "iframe_url": null, 
            "image_height": null, 
            "image_layout": "auto", 
            "image_url": null, 
            "image_width": null, 
            "intro_background_color": null, 
            "intro_text_color": null, 
            "is_published": true, 
            "media_type": null, 
            "override_end": null, 
            "override_start": null, 
            "pdf_height": null, 
            "pdf_numpages": null, 
            "pdf_thumbnail_url": null, 
            "pdf_url": null, 
            "pdf_width": null, 
            "priority": "low", 
            "schedule_end": "2019-07-03T05:04:47.364390-04:00", 
            "schedule_start": "2019-06-26T05:04:47.364343-04:00", 
            "show_data_source_in_player": true, 
            "show_post_in_player_window": true, 
            "show_publication_time": false, 
            "show_text_in_ticker": false, 
            "show_title_in_player": true, 
            "subtitle": null, 
            "template": "video-upload", 
            "text_color": null, 
            "text_layout": "auto", 
            "title": "Big Buck Bunny!", 
            "uploaded_file_s3_bucket": "dive-cms-media", 
            "uploaded_file_s3_key": "s/v/81hoxBB9ScmOJh14i7sQ_fb1af103-e5a7-4b76-b3ef-e69d31c9ab2b.mp4", 
            "uploaded_file_size_bytes": 1055736, 
            "video_filename": "fb1af103-e5a7-4b76-b3ef-e69d31c9ab2b.mp4", 
            "video_url": "https://cdn.filestackcontent.com/4t8t8NPQTruDXKG4YqPH", 
            "youtube_url": null
        }
    }